local originalCFrame
local head = player.Character:WaitForChild("Head")
if head then
originalCFrame = head.CFrame
end
player:LoadCharacter()
if originalCFrame then
head.CFrame = originalCFrame
end
Seems to not work. I’ve also tried humanoidDescription but that seems to not work either.
Here is my full code -
local Refresh = {}
function Refresh.Refresh(player)
if player.Character == nil then
warn("Character does not exist")
return
end
pcall(function()
local event = game.ReplicatedStorage.EVENTS.RefreshEvent
event:FireClient(player)
local Pos = player.Character:GetPrimaryPartCFrame() -- getting OG position
task.wait()
player:LoadCharacter() -- refreshing character
player.Character:SetPrimaryPartCFrame(Pos) -- setting new position
if player.Character:FindFirstChild("ForceField") then -- destroying forcefield
player.Character["ForceField"]:Destroy()
end
end)
end
return Refresh
Local Script in StarterPlayerScripts :
game.ReplicatedStorage.EVENTS.RefreshEvent.OnClientEvent:Connect(function()
local angle = workspace.Camera.CFrame
game.Players.LocalPlayer.CharacterAdded:Wait()
task.wait(0.02) --this changes the camera angle at the perfect time
workspace.Camera.CFrame = angle
end)
local c = player.Character or player.CharacterAdded:Wait()
local humDesc = game:GetService("Players"):GetHumanoidDescriptionFromUserId(player.UserId)
local hum = c:WaitForChild("Humanoid")
hum:ApplyDescription(humDesc)
Seems to not do anything at all, for the main R15 character.
Works for my Bloxikin Character.
Also doesn’t remove the other accessories though.
local Refresh = {}
function Refresh.Refresh(player)
local c = player.Character or player.CharacterAdded:Wait()
local humDesc = game:GetService("Players"):GetHumanoidDescriptionFromUserId(player.UserId)
local hum = c:WaitForChild("Humanoid")
hum:ApplyDescription(humDesc)
end
return Refresh
Should I create an event, and fire to server? Even though this is already in serverscriptservice?
Hey Twin, its zer from your server. I was able to figure out how your multi-refresh issue occurred.
Caused by (i believe) your command handler. I made a fresh command handler to test it, and got the same result as you. After adding a valid check, the command ran once, and once only.
However, I dont believe your camera part is fixable. If seen on the API for camera, any edits can occur in ‘StarterPack’ I think.
But I was able to fix the command.
Working Code:
--[ Basic command handler by deathllyhalIows ] -
--[ Services
local Players = game:GetService('Players')
--[ Variables
local Prefix = "/" --/ Set this to be whatever desired
--[ Commands
local CommandsTable = {
{
CommandName = 'Refresh',
CommandAliases = {'re', 'refresh', 'respawn'}, -- What the message has to contain to be a command. Example: /re, /refresh, etc
CommandFunction = function(Caller)
local char = workspace[Caller.Name] --/ Makes sure the character exists rather .Character
local HRP = char.HumanoidRootPart
local RefreshCF = HRP.CFrame
Caller:LoadCharacter()
char:WaitForChild('Humanoid')
workspace[Caller.Name].HumanoidRootPart.CFrame = RefreshCF --/ Character Respawns, did this just incase. I believe the variable would work the same however
end,
};
};
Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message)
local Args = Message:split(" ") --/ Incase you add more commands, this is how you get arguments provided easily.
local IsCommand = false
for index, cmd in pairs(CommandsTable) do
for _, alias in pairs(cmd.CommandAliases) do
if string.match(alias:lower(), string.gsub(Message:lower(), Prefix, "")) then
IsCommand = true -- Validate the command
end
end
if IsCommand then --/ If the message is truly a command, run ONCE
cmd.CommandFunction(Player) --/ Include the args needed per command!!
end
end
end)
end)