Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.