Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- RS = game:GetService("ReplicatedStorage")
- runCommand = Instance.new("RemoteEvent")
- runCommand.Parent = RS
- runCommand.Name = "runCommand"
- r_sendOutput = Instance.new("RemoteEvent")
- r_sendOutput.Name = "sendOutput"
- r_sendOutput.Parent = RS
- text = ""
- function getParent(arg_parent, v)
- local raw_parent = arg_parent .. "."
- local parent
- local prevParentEnd = 0
- local val = v
- for i=0, string.len(raw_parent) do
- if string.sub(raw_parent, i, i) == "." then
- if val == 1 then
- parent = game[string.sub(raw_parent, prevParentEnd, i-1)] -- -1 to remove whitespace
- prevParentEnd = i
- val = val + 1
- else
- parent = parent[string.sub(raw_parent, prevParentEnd+1, i-1)] -- -1&+1 to remove whitespace
- prevParentEnd = i
- end
- end
- end
- return parent
- end
- COMMAND = {
- ["new"] = function(Player, command, args)
- local new = Instance.new(args[1])
- new.Name = args[2]
- new.Parent = getParent(args[3], 1)
- local EXTRAS = {
- ["Part"] = function ()
- new.Position = Vector3.new(args[4], args[5], args[6])
- new.Size = Vector3.new(args[7], args[8], args[9])
- new.BrickColor = BrickColor.new(args[10], args[11], args[12])
- if args[13] == "false" then
- new.Anchored = false
- else
- new.Anchored = true
- end
- if args[14] == "false" then
- new.CanCollide = false
- else
- new.CanCollide = true
- end
- new.Transparency = args[15]
- text = "Created a new Part '"..args[2].."' at "..tostring(new.Parent).. "pos ["..args[4]..", "..args[5]..", "..args[6].."] size ["..args[7]..", "..args[8]..", "..args[9].."]"
- text = text .. "\n Anchored: "..args[13]..", CanCollide: "..args[14]..", Transparency: "..args[15]
- r_sendOutput:FireClient(Player, "TextLabel", "green", text, 2)
- end
- }
- if EXTRAS[args[1]] ~= nil then
- EXTRAS[args[1]]()
- else
- text = "Created a new ["..args[1].."] '"..args[2].."' at "..tostring(new.Parent)
- r_sendOutput:FireClient(Player, "TextLabel", "green", text, 1)
- end
- end,
- ["delete"] = function(Player, command, args)
- local target = getParent(args[1], 1)
- target:Destroy()
- text = "Deleted " .. tostring(target)
- r_sendOutput:FireClient(Player, "TextLabel", "green", text, 1)
- end,
- ["move"] = function(Player, command, args)
- local target = getParent(args[1], 1)
- local destination = getParent(args[2], 1)
- target.Parent = destination
- text = "Moved ["..tostring(target).."] to ["..tostring(destination).."]"
- r_sendOutput:FireClient(Player, "TextLabel", "green", text, 1)
- end
- }
- function f_runCommand(Player, command, args)
- print("Sender: " ..Player.Name)
- print("Command: " ..command .. " ["..string.len(command).."]")
- print("Args: ")
- for _n, _a in pairs(args) do
- print(" ".._n.. " " .._a .. " ["..string.len(_a).."]")
- end
- if COMMAND[command] ~= nil then
- COMMAND[command](Player, command, args)
- else
- text = "Command ["..command.."] does not exist. Type !help to view all possible commands and their syntax."
- r_sendOutput:FireClient(Player, "TextLabel", "red", text, 1)
- end
- end
- runCommand.OnServerEvent:connect(f_runCommand)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement