CharacterScripts not running when using custom spawning

Hey everybody, I’m having an issue with my characterscripts. I’m using a custom spawning system, where every time the player sends a request through a RemoteEvent, player:LoadCharacter() gets called on the server and the player respawns. However, due to this, none of my characterscripts seem to be running.

I tried putting a basic character script with only:

print("Running")

and it’s not printing. Nothing’s working. However, when I use regular character spawning, everything seems to work fine.

Here’s the character spawning script

-- davidslevs
-- This script handles deploying characters
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local DeployRequestEvent = ReplicatedStorage.Remotes.DeployRequest
Players.CharacterAutoLoads = true

-- Clean up the character when it dies
Players.PlayerAdded:Connect(function(Player)
    Player:SetAttribute("CanDeploy", true)
    Player.CharacterAdded:Connect(function(Character)
        Player:SetAttribute("CanDeploy", false)
        Character.Parent = workspace
        Character:WaitForChild("Humanoid").Died:Connect(function()
            task.wait(Players.RespawnTime)
            Player:SetAttribute("CanDeploy", true)
        end)
    end)
end)

DeployRequestEvent.OnServerEvent:Connect(function(Player)
    -- Don't respawn if the dude is already in the game
    if Player:GetAttribute("CanDeploy") == false then return end
    Player:LoadCharacter()
end)

Shouldn’t CharacterAutoLoads be set to false since you’re loading characters manually? You should check if the character scripts in StarterCharacterScripts are actually inside the player’s character. If they are, then are they enabled? If they’re not in the player’s character, then you can just add this code after the Player:LoadCharacter().

for i, v in pairs(game.StarterPlayer.StarterCharacterScripts:GetChildren()) do
	local clone = v:Clone()
	clone.Parent = Player
	clone.Enabled = true
end

It’s set to false because I was testing it.
When it is false, the scripts are in the character, and they’re enabled, but they don’t run. I don’t want to manually clone them since that would be potentially unreliable.

Fixed. Setting the Character’s parent to workspace was breaking the LocalScripts from running in the character. I simply removed the line.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.