Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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.

1 comment

0

I misread the title as FindFirstChild instead of FirstFindChild

1 answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.