Hello! I’m not an advanced scripter or anything and I’m not that experienced with RemoteEvents.
I am attempting to make some sort of placing system. For this part however, the game detects when a user presses R on their keyboard to then send a RemoteEvent. A server script then detects this and (here’s where it all goes wrong:) is meant to :ClearAllChildren() of a specific folder found in Workspace. (So when the user wishes to clear all the traffic cones they’ve placed, they press R and they all get deleted)
LocalScript code:
local UIS = game:GetService("UserInputService")
local Tool = script.Parent
Tool.Activated:Connect(function()
UIS.InputBegan:Connect(function(input)
if input == Enum.KeyCode.R then
game.ReplicatedStorage.ClearCone:FireServer()
end
end)
end)
ServerScript code:
game.ReplicatedStorage.ClearCone.OnServerEvent:Connect(function()
game.Workspace.PlacedCones:ClearAllChildren()
end)
Just to be clear, here are the order of events: (1 and 2 do not apply for now)
- User equips the tool.
- User clicks to place cones.
- If the user wants to delete the cones, they equip the tool and then press R. (when the RemoteEvent is fired)
- The cones are deleted. (when the RemoteEvent is fired)
I would very much appreciate any help! Additionally, if you would like to give me any feedback on this post or my code please do so as I am always looking to improve.
There are no errors in the output too!