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.
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)
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.
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:
script.Parent.MouseButton1Down:Connect(function()
game.ReplicatedStorage.RemoteEvent:FireServer()
end)
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:
script.Parent.MouseButton1Down:Connect(function()
script.RemoteFunction:InvokeServer()
end)
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
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.
script.Parent.MouseButton1Down:Connect(function()
script.RemoteEvent:FireServer()
end)
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)
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.
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.