Okay I did some research, and made a little rough draft of the script, I'm not that well on scripting. Some of you already know, I'm still learning. But, this is what this is for.
So in short, I want to make it where people can say on the chat "!refresh!", and then their character would reload. Kind of like from admin commands like Kohl's or HD admin, but just so everyone can say it I guess without having to go into the admin script and change it up and such.
Okay so my references are here: https://developer.roblox.com/en-us/recipes/Add-Chat-Commands so it is saying to basically completely kill the character, and then re-spawn at the spawn point, but I want it to where you stay in the same location you once were when you refresh.
So here is the script, or rough draft. I know it is already wrong (hence to it isn't working), probably because I put two different functions as one. I just don't really know how to put it together, and I really need help here.
local function onPlayerChatted(player,message) if message == '!refresh' and player.Character and player.Character:FindFirstChild()then game.Players.PlayerAdded:connect(function(player) wait(.5) player:Loadcharacter() end) end end
you could make it kill the player, and have an instant respawning scripts activate so it looks like nothing happened. hope this helped :p
local function onPlayerChatted(player,message) if message == '!refresh' and player.Character and player.Character:FindFirstChild()then game.Players.PlayerAdded:connect(function(player) wait(.5) player:Loadcharacter() end) end end game.Players.PlayerAdded:Connect(function(plr) plr.Chatted:Connect(function(msg) onPlayerChatted(plr,msg) end) end)
this will fire the function when the player chats
Before you respawn the character, save the position of their HumanoidRootPart, and then after calling LoadCharacter on it, you can call :MoveTo(HumanoidRootPart.Position) on their Character Model. Hope this helped!