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

Why doesnt my teleporting tool know when the player clicks?

Asked by 6 years ago

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

Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
6 years ago

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.

Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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)
0
I didn’t ask for an inefficient workaround, I asked for what’s wrong with my script. andrewcooke582 -52 — 6y
0
alright boss.. lmao smh awesomeipod 607 — 6y
0
did you not read my whole answer or was the script to complex for you to interpret? awesomeipod 607 — 6y
0
alright idiot.. lmao smh andrewcooke582 -52 — 6y
View all comments (2 more)
0
did you not read my whole post or was the question to complex for you to interpret? andrewcooke582 -52 — 6y
0
Don’t be harsh to others like that,he was just trying to help. Lugical 425 — 5y

Answer this question