#tp to spawn
1 messages · Page 1 of 1 (latest)
Just connect a UI button to a function that changes the humanoidRootPart's location. (you can use task.delay for the delay
i already have the ui and it tps i just dont know how to add a timer to the tp
task.delay
how i do that
look at the docs
what do i look for on there
task.delay...
** You are now Level 1! **
local thread = task.delay(5, function()
print("Hello world!")
end)
task.cancel(thread)
that's from the4 docs of task.cancel...
Scroll up
that just shows you how to cancel a task.delay (or any thread to be frank)
?
reading sure is difficult
but what the script and where on the gui do i put it
Learn how to read (and just use) the docs, it will be the most important thing you can learn when using the roblox engine
i know how do read i js needed ur attention
put it on whatever you wanna delay, and for you you would just insert your tp logic into a delay coroutine, so it would be something like this
task.delay(5, function()
--Blah
--Blah
--Blah
--Tp Player to place
end)
thats the whole script?
yeah just put your tp stuff into a task.delay function
and the number up top is the delay in seconds
so i keep the blahs?
no, those are comments, replace the comments with your tp script that works
where d oi place this script
okay, show me your script rn that tps the player on click
show me the script that is doing this
local plr = script.Parent.Parent.Parent.Parent.Parent
local char = plr.Character
script.Parent.MouseButton1Click:Connect(function()
char.HumanoidRootPart.CFrame = workspace.nos.CFrame
end)
local plr = script.Parent.Parent.Parent.Parent.Parent
local char = plr.Character
script.Parent.MouseButton1Click:Connect(function()
task.delay(5, function()
char.HumanoidRootPart.CFrame = workspace.nos.CFrame
end)
end)
do you see what I did?
so i copy that one and replace it
** You are now Level 2! **
also, what you could've done is this:
local plr = script.Parent.Parent.Parent.Parent.Parent
local char = plr.Character
script.Parent.MouseButton1Click:Connect(function()
task.wait(5)
char.HumanoidRootPart.CFrame = workspace.nos.CFrame
end)
yes
how long have you been scripting?
i did a lot in 2020 but quit and just came back a few days ago
okay, just make sure to keep up with coding, and I agree with the other guy, learning to read documentation and really understand how parts of the roblox engine works is important
okay i apreciate it, but one last thing is it a whole other script to make it count down from 5? so people know
What do you mean?
like you want text so show it counting down?
so this script is a server script right? The script that you copied this text into
what do you mean?
is the script that you teleport your player with, a server or client script?
okay
** You are now Level 3! **
did you paste it into a server or local script?
its a local script
Okay I'd recommend watching this vid if you want more info, but right now your script has a massive problem, where the player is only getting teleported on their screen
in Roblox there is the server and the client, and since what your doing is running on a client script, your player isn't actually teleporting on the server
so what you need to do is keep that local script right, and make it create a new gui with text and have it count down, and also fire to the server once it's done
yes, only the player who is running it on their machine will see it
i just tested it, my brother sees me tp
check the server view
wheres that
right next to the "Play" button in roblox studio you can switch between server and client view
when you click the teleport button on the client side and teleport you'll see that your location is different between the server and client view
Okay, I edited the script
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Player = script.Parent.Parent.Parent.Parent.Parent
local Character = Player.Character
local RemoteEvent = ReplicatedStorage.RemoteEvent -- replace this with where you put your remote event
script.Parent.MouseButton1Click:Connect(function()
--have code here which adds in text to the gui
for Counter = 5, 0, -1 do
Label.Text = Counter -- Replace Label with whatever variable you made for a textlabel object
task.wait(1)
end
RemoteEvent:FireServer(Player) -- make another script which is a server script that teleports the player
end)
you can copy this if you want, listen to the comments and follow them
this code will not work, it's just to show you what to do
already have a tp script
?
okay yeah but it doesn't change the players location on the server side
it changed for my borther