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

RemoteEvent passes nil if Mouse.Target's Parent is a Character. Help?

Asked by
dionant 23
6 years ago

I've got a tool with a LocalScript getting the Mouse's target and passing it to a Script within the same tool. When the tool clicks a Character's right arm (or any other part/hat) the localscript prints "Right Arm" and the Script prints "nil" . However, if the tool clicks a random part, like the ground, the localscript prints 'Ground' and the script also prints 'Ground' . It seems to be an issue with character parts. Help? Here's the code.

--LocalScript "ClickHandler"
Tool = script.Parent
Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()

function Click()
local Part = Mouse.Target
if Part ~= nil then
print (Part)
script.ClickEvent:FireServer(Part)
end

end

Tool.Activated:Connect(Click)

And

--Script "Main"
function Click(Player,Part)
    print (Part)
end



script.Parent.ClickHandler.ClickEvent.OnServerEvent:Connect(Click)

If you're wondering; Main.Parent is the Tool. ClickHandler.Parent is the tool. ClickEvent.Parent is ClickHandler

Any clues? HELP!

Answer this question