Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

I'm getting the error code FirstFindChild is not a valid member of Player "Players.dinnerden"?

Asked by 3 years ago
game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        local humanoid = character:FirstFindChild("Humanoid")
        if humanoid then
            if humanoid.RigType == Enum.HumanoidRigType.R6 then
                local clone = game.ServerStorage:WaitForChild("R6Sword"):Clone()
                clone.Parent = player.Character
            elseif humanoid.RigType == Enum.HumanoidRigType.R15 then
                local clone = game.ServerStorage:WaitForChild("R15Sword"):Clone()
                clone.Parent = player.Character
            end
        end

        character.Humanoid.Die:Connect(function()
            local tag = character.Humanoid:FirstFindChild("creator")
            if tag ~= nil then
                local player = tag.Value
                local expVal = 75
                local exp = player:WaitForChild("Exp")
                exp.Value = exp.Value + expVal
            end
        end)

    end)
end)

I was wondering why I was getting this error code on this script.

0
I misread the title as FindFirstChild instead of FirstFindChild greatneil80 2647 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago

I laughed at this a bit. You misspelled FindFirstChild XDDDDDDD

Correct Script:

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        local humanoid = character:FindFirstChild("Humanoid")
        if humanoid then
            if humanoid.RigType == Enum.HumanoidRigType.R6 then
                local clone = game.ServerStorage:WaitForChild("R6Sword"):Clone()
                clone.Parent = player.Character
            elseif humanoid.RigType == Enum.HumanoidRigType.R15 then
                local clone = game.ServerStorage:WaitForChild("R15Sword"):Clone()
                clone.Parent = player.Character
            end
        end

        character.Humanoid.Die:Connect(function()
            local tag = character.Humanoid:FindFirstChild("creator")
            if tag ~= nil then
                local player = tag.Value
                local expVal = 75
                local exp = player:WaitForChild("Exp")
                exp.Value = exp.Value + expVal
            end
        end)

    end)
end)
Ad

Answer this question