script.Parent.ClickDetector.MouseClick:connect(function(p)
local Torso = game.Players.LocalPlayer.Character:WaitForChild("Torso")
Torso.Anchored = true
if p.Backpack:findFirstChild("Fish") then
p.Backpack:findFirstChild("Fish").Handle.Mesh.VertexColor = Vector3.new(0.4,0.4,0.4)
wait(2)
Torso.Anchored = false
end
end)
✓ ANSWER ACCEPTED
Why isnt this working? (Very short and easy code, and its in a localscript)
2 answers
✓ Accepted answer
script.Parent.ClickDetector.MouseClick:connect(function(p)
local Torso = p.Character:WaitForChild("Torso")
Torso.Anchored = true
if p.Backpack:findFirstChild("Fish") then
p.Backpack:findFirstChild("Fish").Handle.Mesh.VertexColor = Vector3.new(0.4,0.4,0.4)
wait(2)
Torso.Anchored = false
end
end)
I'm not sure why you were trying to use LocalPlayer when MouseClick returns the player?
When the MouseClick event is fired, it gives the player who clicked as an argument, in this case 'p.'
Try this.
script.Parent.ClickDetector.MouseClick:connect(function(p)
if p.Character then -- Checks if the players character isn't nil
local torso = p.Character:FindFirstChild("Torso")
local fish = p.Backpack:FindFirstChild("Fish")
if torso then -- if torso exists
torso.Anchored = true
if fish then -- if fish exists
p.Backpack.Fish.Handle.Mesh.VertexColor = Vector3.new(0.4,0.4,0.4)
wait(2)
end
torso.Anchored = false
end
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Only the torso anchored thing doesnt work