The character is being defined in Roblox Studio but not in Roblox Player

links

This is the link for the .rbxl file. You can use this code freely as long as you help solve the issue!

Also you can test it in-game if you need to.

script

for defining character:

local character
local collider

local characterLoadEvent = game.ReplicatedStorage:WaitForChild("CharacterLoadEvent")
characterLoadEvent:FireServer()

player.CharacterAdded:Connect(function(newCharacter: Model)
	character = newCharacter
	collider = newCharacter:WaitForChild("Collider")
end)

hierarchies

image

image

video

1 Like

This is likely because the character is being added before the client loads. Simply check if the character has already been added. Your script would look like this:

local character
local collider

local characterLoadEvent = game.ReplicatedStorage:WaitForChild("CharacterLoadEvent")
characterLoadEvent:FireServer()

local function onCharacterAdded(newCharacter)
	character = newCharacter
	collider = newCharacter:WaitForChild("Collider")
end

if player.Character then
   onCharacterAdded(player.Character)
end

player.CharacterAdded:Connect(onCharacterAdded)
1 Like

The character still isn’t loading. I want to be able to load the character manually but it seems to be causing some issues.

image

1 Like