RespawnScript in StarterCharacterScripts
local plr = game.Players.LocalPlayer local char = script.Parent local humanoid = char:WaitForChild("Humanoid") humanoid.Died:Connect(function() game.ReplicatedStorage.LoadChar:FireServer(plr) print("Char loaded.") end)
Script in ServerScriptService
local items = game.ReplicatedStorage:WaitForChild("Characters") game.ReplicatedStorage.LoadChar.OnServerEvent:Connect(function(plr) plr:LoadCharacter() print(plr.Name) local charClone = items.Chicken:Clone() charClone.Name = plr.Name local rootPart = charClone:FindFirstChild("HumanoidRootPart") or charClone:FindFirstChild("Torso") local plrRoot = plr.Character:FindFirstChild("HumanoidRootPart") or plr.Character:FindFirstChild("Torso") plr.Character = charClone if rootPart and plrRoot then rootPart.CFrame = plrRoot.CFrame end charClone.Parent = workspace char = plr.Character end)
This is what happens: https://youtu.be/X7syZpASTQA
Understanding:
When you're using StarterPlayer.StarterCharacterScripts
, anything you do that could potentially destroy the script or it's ancestors will stop the code from running. While your message may not be printing in the LocalScript, it doesn't print because the Character was requested to load prior. You also cannot set Player.Character
because the property is not available for scripts with low security context level.
Script from the Server
local ReplicatedStorage: ReplicatedStorage = game:GetService("ReplicatedStorage") local RemoteEvent: RemoteEvent = ReplicatedStorage:WaitForChild("LoadChar", math.huge); RemoteEvent.OnServerEvent:Connect(function(Player, ...) return Player:LoadCharacter() end)
How do you make your player's Character a Chicken?: You can use StarterPlayer's special feature; StarterCharacter. Learn more about StarterPlayer here.
NOTE: You may not need to use any scripting to set the StarterCharacter, therefore you can abandon the script, so long as you are either 1; loading the player's character from a spawn & respawn manager or having Players.CharacterAutoLoads set to true.