So I was just wondering how to reset the character’s animations, welds, attachments, etc. to its original values without actually having to kill the character. Is there a simple way to do this? That would be much appreciated. Thanks!
The problem is that for some reason even if there are no welds, my character’s arms become very stiff and don’t follow the animations at all after being manipulated through code. Do you know what the reason for this is? And how to fix? Thanks.
You can teleport the player after you load their character.
local Character = game.Players.LocalPlayer.Character
-- Changing Posiiton of character
Character:WaitForChild("HumanoidRootPart").Posiiton = OldCharacter.Position
Soo… i don’t know, if this is efficient and will work but, let me share with you. Here is script:
local prevspawn = game.Workspace.SpawnLocation -- You can set this if you have a teams in your game and you need to spawn at certain point
local HumrpPos = Player.Character.HumanoidRootPart.Position
game.Workspace.CarrySpawn.Position = Vector3.new(HumrpPos.X,0,HumrpPos.Z) --Setting the CarrySpawn Position to HumanoidRootPart Position
Player.RespawnLocation = game.Workspace.CarrySpawn --The spawn you will carry
Player:LoadCharacter()
task.wait(0.5) -- setting this because sometimes :LoadCharacter() works after the sequence front of it
Player.RespawnLocation = prevspawn
I explained it in the code, but let me explain it again. In this code we have a carry spawn point, so when you choose to reset your character, that spawn point will be below your character and you will spawn at exactly the same spot where you reset it. And when you choose to reset manually, spawn point will be the same spawn point you had before. When you reset, your character does not move, only the character’s animation will be loaded(It moves if spawnlocation is not oriented to HumanoidRootPart). Here is the script to test it out:
--LocalScript
local UIS = game:GetService("UserInputService")
local Remote = game:GetService("ReplicatedStorage").RemoteEvent
UIS.InputBegan:Connect(function(input,gpe)
if gpe then return end
if input.KeyCode == Enum.KeyCode.E then
Remote:FireServer()
end
end)
--ServerScript
local Remote = game:GetService("ReplicatedStorage").RemoteEvent
game:GetService("Players").PlayerAdded:Connect(function(Player)
Remote.OnServerEvent:Connect(function()
print("yo")
local prevspawn = game.Workspace.SpawnLocation -- You can set this if you have a teams in your game and you need to spawn at certain point
local HumrpPos = Player.Character.HumanoidRootPart.Position
game.Workspace.CarrySpawn.Position = Vector3.new(HumrpPos.X,0,HumrpPos.Z) --Setting the CarrySpawn Position to HumanoidRootPart Position
Player.RespawnLocation = game.Workspace.CarrySpawn --The spawn you will carry
Player:LoadCharacter()
task.wait(0.5) -- setting this because sometimes :LoadCharacter() works after the sequence front of it
Player.RespawnLocation = prevspawn
end)
end)
Also dont forget to create your own Spawnlocation or i can automate the script.
Thank you a LOT for this, it works very well and presents a good solution to my problem. My only other question would be is there a way to rotate the camera so that my character can face the same direction it was in before they reset? Thanks so much again.
Here is the code i just added rotation. And okay it works i were just trying something more complicated.
--ServerScript
local Remote = game:GetService("ReplicatedStorage").RemoteEvent
game:GetService("Players").PlayerAdded:Connect(function(Player)
Remote.OnServerEvent:Connect(function()
print("yo")
local prevspawn = game.Workspace.SpawnLocation -- You can set this if you have a teams in your game and you need to spawn at certain point
local HumrpPos = Player.Character.HumanoidRootPart.Position
game.Workspace.CarrySpawn.Position = Vector3.new(HumrpPos.X,0,HumrpPos.Z) --Setting the CarrySpawn Position to HumanoidRootPart Position
game.Workspace.CarrySpawn.Rotation = Player.Character.HumanoidRootPart.Rotation
Player.RespawnLocation = game.Workspace.CarrySpawn --The spawn you will carry
Player:LoadCharacter()
task.wait(0.5) -- setting this because sometimes :LoadCharacter() works after the sequence front of it
Player.RespawnLocation = prevspawn
end)
end)
--LocalScript
local UIS = game:GetService("UserInputService")
local Remote = game:GetService("ReplicatedStorage").RemoteEvent
UIS.InputBegan:Connect(function(input,gpe)
if gpe then return end
if input.KeyCode == Enum.KeyCode.E then
Remote:FireServer()
end
end)
Thanks a bunch again, I tried it and it works very well. My only question to you is that sometimes the red dying UI shows up and it messes with the camera so that the camera doesn’t show the back of the character like 92% of the time it does. I was wondering if there was a work around with this or if its just an internal feature in Roblox and there’s not much to do about it. Either way, you really helped me and I appreciate it a lot. Thank you.