local debounce = true
local player = script.Parent.Parent.Parent.Parent
local target = game.Workspace:WaitForChild("50")
script.Parent.MouseButton1Click:connect(function()
if debounce == true then
debounce = false
player.Character.HumaniodRootPart.CFrame = target.CFrame * CFrame.new(-261.56, 53.52, 301.780)
-- Want Cooldown?
for i = 5,1,-1 do
wait(1)
script.Parent.Text = i
end
wait(1)
script.Parent.Text = "Skip to stage 50!"
debounce = true
end
end)
0 I'm making a OBBY and I made a skip to different stage buttons but it's not working?
2 answers
From the information that you've given me, the script is either not functioning accordingly because this is NOT a local script, or because the CFrame value is incorrect.
In line 2, you defined player as player = script.Parent.Parent.Parent.Parent, which isn't incorrect, but there's a more efficient way to define the player.
In line 8, the defined CFrame Values teleports the player TO the target position, and then CFrames them (-261.56, 53.52, 301.780) out relative to the target CFrame, which may be the primary reason to why this script isn't working as you want to. So, allow me to propose an annotated solution!
Use a LOCAL SCRIPT (unless you already did), and place it in the ButtonGUI.
local debounce = true
local player = game.Players.LocalPlayer --Defines the player through local script
local target = game.Workspace:WaitForChild("50")
script.Parent.MouseButton1Click:connect(function()
if debounce == true then
debounce = false
game.Workspace[player.Name].HumanoidRootPart.CFrame = target.CFrame + Vector3.new(0, 5, 0) --This teleports the player's character 5 studs above the target
for i = 5, 1, -1 do
wait(1)
script.Parent.Text = i
end
wait(1)
script.Parent.Text = "Skip to stage 50!"
debounce = true
end
end)
From the information that you've given me, the script is either not functioning accordingly because this is NOT a local script, or because the CFrame value is incorrect.
In line 2, you defined player as player = script.Parent.Parent.Parent.Parent, which isn't incorrect, but there's a more efficient way to define the player.
In line 8, the defined CFrame Values teleports the player TO the target position, and then CFrames them (-261.56, 53.52, 301.780) out relative to the target CFrame, which may be the primary reason to why this script isn't working as you want to. So, allow me to propose an annotated solution!
Use a LOCAL SCRIPT (unless you already did), and place it in the ButtonGUI.
local debounce = true
local player = game.Players.LocalPlayer --Defines the player through local script
local target = game.Workspace:WaitForChild("50")
script.Parent.MouseButton1Click:connect(function()
if debounce == true then
debounce = false
game.Workspace[player.Name].HumanoidRootPart.CFrame = target.CFrame + Vector3.new(0, 5, 0) --This teleports the player's character 5 studs above the target
for i = 5, 1, -1 do
wait(1)
script.Parent.Text = i
end
wait(1)
script.Parent.Text = "Skip to stage 50!"
debounce = true
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Thank you I made the silly mistake of not using a local script!