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

TeleportWhenClicked not working, I don't know how to fix this. Any help?

Asked by 6 years ago
local debounce = true
local player = script.Parent.Parent.Parent.Parent
local target = game.Workspace:WaitForChild("TeleportTarget")

script.Parent.MouseButton1Click:connect(function()
   if debounce == true then
      debounce = false
      player.Character.HumaniodRootPart.CFrame = target.CFrame * 
      CFrame.new(0,3,0)

I wanted it to when you click you would teleport to a brick.

1 answer

Log in to vote
0
Answered by 6 years ago

Try putting that in a LocalScript where local player = game.Players.LocalPlayer. Also debounce should = false and the code should be something like this

script.Parent.MouseButton1Click:connect(function()
if not debounce then
debounce = true
local char = game.Workspace:FindFirstChild(player)
char.HumanoidRootPart.CFrame = CFrame.new(Vector3.new((target.Position))*Vector3.new(0,3,0)
--You could add a wait here if needed
debounce = false
end
end)
0
I messed up at one point. Lin 5 should read: char.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(target.position)*(0,3,0)) Agueroooooo16 15 — 6y
Ad

Answer this question