Help on making a refresh character script

Hi, I’ve been searching for a week on how to make a “Refresh Character” script.

Something like this:

Uploading: Screen Recording 2021-03-06 at 01.43.24.mov…

Thanks, I would appreciate if someone knows how to help me.

For some reason I can’t upload the video.

Are you talking about:

Player:LoadCharacter()

Basically when you press a button you will refresh. (You wont die and spawn at a spawn location)

LocalScript:

local Player = game.Players.LocalPlayer

script.Parent.MouseButton1Down:Connect(function()
    Player:LoadCharacter()
end)
1 Like

Thanks! But whats the difference between MouseButton1Click and MouseButton1Down?

I don’t really know what the difference is, but MouseButton1Click sometimes won’t work, that’s why I used MouseButton1Down.

1 Like

Why isn’t the script working when I click the button? (Text button)

Try this:

local Player = game.Players.LocalPlayer

script.Parent.MouseButton1Down:Connect(function()
    Player:LoadCharacter(true)
end)

If it doesn’t work, then try the alternative.

Alternative:

1. Local Script in Button
script.Parent.MouseButton1Down:Connect(function()
	game.ReplicatedStorage.RemoteEvent:FireServer()
end)
  1. Place RemoteEvent named “RemoteEvent” in ReplicatedStorage.
3. Server Script in ServerScriptService
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(Player)

Player:LoadCharacter(true)

end)

Alternative 2:
If you don’t want everything to be spread out and messy then try this alternative:

1. LocalScript in Button
script.Parent.MouseButton1Down:Connect(function()
	script.RemoteFunction:InvokeServer()
end)
  1. Create a RemoteFunction named “RemoteFunction” in LocalScript
3. Create a Server Script in Button
local Val = Instance.new("Vector3Value")
Val.Name = "PlrPosition"
Val.Parent = script.Parent

script.Parent.LocalScript.RemoteFunction.OnServerInvoke = function(Player)
	local X = Player.Character.HumanoidRootPart.Position.X
	local Y = Player.Character.HumanoidRootPart.Position.Y
	local Z = Player.Character.HumanoidRootPart.Position.Z
	
	Val.Value = Vector3.new(X,Y,Z)
		Player:LoadCharacter(true)
	wait(0.2)
	    Player.Character.HumanoidRootPart.Position = Val.Value
end
2 Likes

Remember to put the script in the button…
IF you didn’t do that at first, then that should have been the problem. (the button isn’t working), otherwise, try the last post.

Yeah, It works but I don’t want to re-spawn at a spawn location. I want to spawn where I clicked the button. (If that made sense) Thank you!

Try Alternative 2…------------

This should work:

Features:
-- Refresh Character
-- Teleport to last position.

  1. Go to the GUI and change ResetOnSpawn property to false. (Uncheck it)
2. Create A LocalScript in Button
script.Parent.MouseButton1Down:Connect(function()
	script.RemoteEvent:FireServer()
end)
  1. Create RemoteEvent named "RemoteEvent’ in LocalScript.
4. Create A Server Script in Button.
local Val = Instance.new("Vector3Value")
Val.Name = "PlrPosition"
Val.Parent = script.Parent
local db = false

local Connection 

function CharacterAdded(Character)
	repeat wait()
		Character:WaitForChild("HumanoidRootPart").Position = Vector3.new(Val.Value.X,Val.Value.Y,Val.Value.Z)
	until 
	Character:WaitForChild("HumanoidRootPart").Position == Vector3.new(Val.Value.X,Val.Value.Y,Val.Value.Z)
	Connection:Disconnect()
	db = false
end

script.Parent.LocalScript.RemoteEvent.OnServerEvent:Connect(function(Player)
	Connection = Player.CharacterAdded:Connect(CharacterAdded)
	Val.Value = Player.Character.HumanoidRootPart.Position
	wait(0.4)
	if db == false then
		db = true
		wait(0.05)
		Player:LoadCharacter(true)
	end	
end)
  1. Good To Go!
1 Like

Button1Down means when the button is down, but the click is triggered when your actual click is triggered AND the button is down.

You can save the humanoid root part cframe before you update your character and then set the hrp cframe to the saved cframe that way you will stay in the same spot after updating the character.

1 Like

Why don’t you just teleport them instead of loading character? You can use :MoveTo or use CFrames.

The way you said “Refresh” Character means that you want them to respawn essentially, but if you don’t want them to die I would recommend just teleporting them to the spawn location.