Hello, I'm working on something and I tried to fix this problem many times, I used RemoteEvents, and still nothing. Can someone help me please?
--local script script.Parent.Touched:Connect(function(hit) if hit.Name == "Breakable" then local currentbreak = hit.Name script.Parent.Parent.RemoteEvent:FireServer(currentbreak) else return end end)
and the server side script
script.Parent.RemoteEvent.OnServerEvent:Connect(function(currentbreak) currentbreak.Anchored = false end)
Note: There are multiple breakable bricks in the workspace, and the script should find a specific one, that was touched by the tool part. So I can't do something like this:
game.Workspace.Breakable.Anchored = false
Thanks!
Hello.
Here are the errors you made:
Here is a fix:
Server Script:
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player, object) if object.Name == "Breakable" then -- Checks should be made on the server since an exploiter could bypass the Client checks. object.Anchored = false -- UnAnchoring the object. end end)
Tool LocalScript:
local DelayTime = 5 local Delay = false script.Parent.Handle.Touched:Connect(function(object) if object.Name == "Breakable" and not Delay then -- Checks if the object name is "Breakable" and if Delay is false (Delay == false is the same as "not delay") Delay = true -- Makes Delay true game.ReplicatedStorage.RemoteEvent:FireServer(object) -- Fires the object to the server. wait(DelayTime) -- Wait the DelayTime (5 seconds) Delay = false -- After 5 seconds, the delay will become False. end end)