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

Why doesnt my teleporting tool know when the player clicks?

For some reason my tool doesn’t work when I click and I have no idea why. Local script inside tool:

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
script.Parent.Activated:Connect(function()
Player.Character:MoveTo(Mouse.Hit.Position)
end)

Please help

2 answers

✓ Accepted answer

Make sure your Tool has a Part named "Handle" inside it.

The Activated event will not fire if the tool's handle is missing, unless you set the RequiresHandle property of the tool to false, which you should do if you want your tool not to have any parts which are held by your player.

Instead of Activated, use Mouse.Button1Down

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

local Tool = script.Parent
local Equipped = false -- to make sure that the tool doesn't activate when unequipped

Mouse.Button1Down:Connect(function()
	if Equipped then 
		Player.Character:MoveTo(Mouse.Hit.Position)
	end
end)

Tool.Equipped:connect(function() Equipped = true end)

Tool.Unequipped:connect(function() Equipped = false end)

6 comments

0

I didn’t ask for an inefficient workaround, I asked for what’s wrong with my script.

0

alright boss.. lmao smh

0

did you not read my whole answer or was the script to complex for you to interpret?

0

alright idiot.. lmao smh

0

did you not read my whole post or was the question to complex for you to interpret?

0

Don’t be harsh to others like that,he was just trying to help.

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