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

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

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

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)

1 comment

0

I messed up at one point. Lin 5 should read: char.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(target.position)*(0,3,0))

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