I am currently trying to make a Teleport Service script. But it is running slow. So, I came up with an idea to make it when the players touch a specific part a countdown starts. And I was wondering. How can I make an if touchedfunction that starts a countdown for the player that touched it? Thanks!
Use the Touched Event that is available on a BasePart (Includes Part, Union, etc…) and then send an event to the client via RemoteEvent telling them to start a Countdown. After you sent the event on the server, you can either put directly a wait(10) inside the Server Script or make the client tell the server the countdown is over so the Server can teleport them.
“I’m a bad scripter” isn’t an excuse to not learn. Asking for scripts in general is against the rules. @SimplyData did a good job explaining what is needed to be done, now it’s your turn to try and construct the thing. Please learn the basics before attempting stuff you don’t have an idea on how to do!
local Part = workspace.TouchMeToTeleport
Part.Touched:Connect(function(Hit)
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
if Player then
game.ReplicatedStorage.StartCountdown:FireClient(Player)
end
end)
game.ReplicatedStorage.CountdownDone.OnServerEvent:Connect(function(Player)
-- Teleport Player here
end)
Client (anywhere you can run a LocalScript)
game.ReplicatedStorage.StartCountdown.OnClientEvent:Connect(function()
for i=10,0,-1 do
local timer = i+1
-- Do what you want with timer, it represents the time left
wait(1)
end
game.ReplicatedStorage.CountdownDone:FireServer()
end)
You need to modify this example to your own needs, since as @starmaq said,
Found a solution, in the future I will try to find a solution in the developer hub or I will try to find a solution myself. I will post the solution in a minute…