Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help please how do you make it turn green when sword is in opponents hand?

Asked by 10 years ago

This script, will only make a sword turn green when the player stabs the opponent and the opponent is not holding the sword and having it equipped. Could someone fix this error?

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)

2 answers

Log in to vote
0
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
10 years ago

If LinkedSword is the sword, it would be found in the same place as the Humanoid if it were selected. The only obvious problem would be if it isn't actually named "LinkedSword"

Ad
Log in to vote
-1
Answered by
Hybric 271 Moderation Voter
10 years ago

insert a script inside handle:

function HybricScripts(part)
local h = part.Parent:findFirstChild("Humanoid")
if (h ~= nil) then
script.Parent.Mesh.VertexColor = Vector3.new(0,1,0)
wait(1)
script.Parent.Mesh.VertexColor = Vector3.new(1,1,1)
end
end

script.Parent.Touched:connect(HybricScripts)
0
Didn't work. Wrongmistake 0 — 10y

Answer this question