Ad
Log in to vote
0

Only turns green when opponent's not holding a sword?

Asked by 7 years ago

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)

1 answer

Log in to vote
0
Answered by
Sublimus 992 Moderation Voter
7 years ago

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)

Ad

Answer this question