Hi everyone,
I want a GUI that once clicked, it will reset my character and teleport me to a specific spot. I’m not sure how to do that if there’s scripting involved but any help would be appreciated. Thanks!
Hi everyone,
I want a GUI that once clicked, it will reset my character and teleport me to a specific spot. I’m not sure how to do that if there’s scripting involved but any help would be appreciated. Thanks!
You can maybe use Player:LoadCharacter to (re)load it instantly without killing him, and just after teleport his character to the place you wish for using Humanoid:MoveTo. You can always use other methods to teleport the character, this is simply what I usually use (see this topic)
Paste this in a local script inside your Button:
--//Services
local Players = game:GetService("Players")
--//Variables
local LocalPlayer = Players.LocalPlayer
local Button = script.Parent
--//Controls
local teleportPosition = Vector3.new(100, 100, 100) --//Insert your position
--//Tables
local Connections = {}
--//Functions
Button.MouseButton1Click:Connect(function()
local Humanoid = LocalPlayer.Character and LocalPlayer.Character:FindFirstChildWhichIsA("Humanoid")
if not Humanoid then
return
end
Connections.CharacterAdded = LocalPlayer.CharacterAdded:Connect(function(character)
Connections.CharacterAdded:Disconnect()
Connections.CharacterAdded = nil
task.defer(function()
character:MoveTo(teleportPosition)
end)
end)
Humanoid.Health = 0
end)
Make sure to turn off ResetOnSpawn on the ScreenGui it is located in.
u can disconnect an event with its own function unless im wrong
I’m just using a table to store the connections so it’s easier for access.
Forgot to mention that the “button” or “guibutton” aren’t in the job selection gui. It’s associated with the teams folder. The job selection runs on that. Any way to kinda get pass that? Hard to explain.
You could also use :Once() to avoid having to make a connection to immediately disconnect it after. Documentation
LocalPlayer.CharacterAdded:Once(function(character)
task.defer(function()
character:MoveTo(teleportPosition)
end)
end)
I didn’t even know that existed lol. Thanks for sharing, I’m going to use that in my other projects.