Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a chat command: "!refresh" to reload the character?

Asked by 5 years ago

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

3 answers

Log in to vote
0
Answered by 5 years ago

you could make it kill the player, and have an instant respawning scripts activate so it looks like nothing happened. hope this helped :p

0
LoadCharacter() is reloads the character, but not telling you kill the players so the players doesn't get back to the spawn ;( Xapelize 2658 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
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

Log in to vote
0
Answered by 4 years ago

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!

Answer this question