So I made a script, that turns green when a player touches another player, but the problem with it is that it will only turn green when a player's not holding a sword. It's supposed to change the meshes color to green whether the player's holding a sword or not. Could somebody fix this?
handle = script.Parent.Handle handle.Touched:connect(function(part) if part.Parent:FindFirstChild("Humanoid") and not part.Parent:FindFirstChild("LinkedSword")then handle.Mesh.VertexColor = Vector3.new(0, 1, 0) else handle.Mesh.VertexColor = Vector3.new(1, 1, 1) end end)
You have this line:
and not part.Parent:FindFirstChild("LinkedSword") --If they are holding a sword it will not run
And it should just be this:
handle = script.Parent.Handle handle.Touched:connect(function(part) if part.Parent:FindFirstChild("Humanoid") then handle.Mesh.VertexColor = Vector3.new(0, 1, 0) else handle.Mesh.VertexColor = Vector3.new(1, 1, 1) end end)