I am scripting a sword and trying to make it function. One of the obvious functions is that a player will take damage when touched by the sword. I have a local script inside the handle of tool and it is supposed to detect when it is touched, it isn't.
Script:
script.Parent.Touched:Connect(function(hit) if hit.Parent == not game.Players.LocalPlayer.Character then print("hit") game.ReplicatedStorage.RemoteEvents.TakeDamage:FireServer(hit.Parent:FindFirstChild("Humanoid"), 20) end end)
This was an idiotic problem. I solved it by changing it like this:
-- old code if hit.Parent == not game.Players.LocalPlayer.Character then -- new code if hit.Parent ~= game.Players.LocalPlayer.Character then