script.Parent.Touched:Connect(function(hit) print("Touched") local d = hit.Parent:FindFirstChild("Humanoid") if d then script.Parent:Destroy() game.workspace.Spawn.Arrow:Destroy() print("Done") end end)
so I tried the same code in a normal script and it worked but it's not working in a local script. what I'm trying to do is to make the parts get destroyed only for the client but it's not working. my goal is to just make the parts disappear for the client only whenever the player touches the part.
You can't use touched in a localscript
So we're gonna use a remote event
Server Script
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then script.Parent:Destroy() game:GetService("ReplicatedStorage"):FindFirstChild("DestroyArrow"):FireClient(game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)) end end)
Local Script
game:GetService("ReplicatedStorage"):FindFirstChild("DestroyArrow").OnClientEvent:Connect(function() game.Workspace.Spawn.Arrow:Destroy() print("Done") end)