I am trying to create an admin command that makes the player’s character be refreshed. I already made it so that if you use the command you reset without going back to spawn but I also have a problem where the spawn gui also resets when using the command. What should I do to avoid resetting the gui?
Here is the code that I’m using:
commands.refresh = function(sender, arguments)
print(sender.Name.." used the refresh command.")
local player = arguments[1]
if player then
local plyr = FindPlayer(player,sender)
if plyr then
local cframe = plyr.Character.HumanoidRootPart.CFrame
plyr:LoadCharacter()
plyr.Character.HumanoidRootPart.CFrame = cframe
print(sender.Name.." refreshed "..plyr.Name.."'s character.")
end
else
local cframe = sender.Character.HumanoidRootPart.CFrame
sender:LoadCharacter()
sender.Character.HumanoidRootPart.CFrame = cframe
print(sender.Name.." refreshed "..sender.Name.."'s character.")
end
end
A tip, you can make this command have a cooldown by using debounce. While in the cooldown, you can set the PlayerGui that you are using and make the Enabled property disabled after finishing (like welcome gui after finishing it).
I am aware of that property but I do need the spawn gui to reset when the player dies so that they can choose where they spawn next to avoid them being spawn camped, but when using the command the gui won’t reset because the character will be put back to the same location.
Either toggle the property in the gui ResetOnSpawn to false or clone the gui before you reset the player then reparent it to the player after they are respawned/refreshed.