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

How Do You Add A Delay To When Your Button Teleports?

So earlier I made a ScreenGUI with a Text Button that would teleport to places around the map. Then I added an animation to it but the Teleport happens instantly without a delay so the animation has no time to play before the teleport. This is the script: wait(1) player = game.Players.LocalPlayer button = script.Parent local debounce = false

function helpme() if not debounce then

	debounce = true
	Head = player.Character.Head
	Head.CFrame = game.Workspace.Gate1.CFrame
	
end

end button.MouseButton1Click:connect(helpme)

while true do wait() debounce = false end. I am Just asking for someone to help me learn how to add a delay to this.

4 comments

0

Doesn't teleporting the head kills the player? I thought only HumanoidRootPart could be CFramed to move the entire character. Also your debounce seems like it won't work, use (if debounce == false then) because i think (if not debounce then) will only work if debounce is nill i guess. also reset debounce to false at the end of the function.

0

For the delay simply put a wait after playing the animation and then cframe the player. Or connect a markerreachedsignal from that animation with the teleport.

0

No teleporting the head also teleports the entire body I just have the block it's teleporting to raised high enough to where it spawns the body on the floor.

0

@Dfozoz not applies to false AND nil conditions

1 answer

If I understand your question correctly, all you need to do is put an integer inside of the parameters of the wait.

Delaying is as simple as wait(n). n represents the number in seconds you want to wait.

Edit: Also please teleport the players HumanoidRootPart and not their head.

3 comments

0

I tried using the wait(n) but when I used it nothing happened and yes I will use the HumanoidRootPart.

0

when you add "wait(n) the "n" is supposed to be changed to a number. the number id how many seconds it will take

0

yes i know that is what i did... for example i put wait(3)

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