Ad
Log in to vote
0

Character cannot be found even with great amounts of time?

Asked by 11 days ago

So I have this code below, and nothing is wrong with it as it warns me that there is no character and there is no errors, but since it never finds the character, I'm wondering why it doesn't find it as when I looked at myself in the player list, my Character was listed as a property.

local Players = game:GetService("Players")
local replstor = game:GetService("ReplicatedStorage")
local marble = replstor.Marble

Players.PlayerAdded:Connect(function(plr)
    local plrmarble = marble:Clone()
    local Character = plr:WaitForChild("Character", 10)
    if Character then
        plrmarble.Position = Character.Torso.Position
    else
        warn("Character not found")
    end
    plrmarble.Name = plr.Name .. "'s " .. "Marble"
    plrmarble.Player.Value = plr
    plrmarble.Parent = workspace
end)

1 answer

Log in to vote
0
Answered by 11 days ago
Edited 11 days ago

The “character” is not a child of player instead it’s a property of player use CharacterAdded:Wait() this will ensure the script resumes after the character is added

Ad

Answer this question