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)
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"
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)