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

How do I add CharacterAdded onto PlayerAdded? (Solved!)

Asked by
ElBamino 153
3 years ago
Edited 3 years ago

Sorry about how I worded the question, I don't know how else to explain. I'm having a hard time with this. So, when the player is added it works but, this is only a one time deal. If the player dies it doesn't work again. I'm wondering how I would change it from PlayerAdded to CharacterAdded? I've been having a hard time with this. If the player has the badge then, clone the tool into the backpack.

This works for a one time PlayerAdded.

local BadgeService = game:GetService("BadgeService")
local BadgeId = 2124743307
local replicatedstorage = game:GetService("ReplicatedStorage")
local tool = replicatedstorage:FindFirstChild("Lucifer")

game:GetService("Players").PlayerAdded:Connect(function(player)
    if BadgeService:UserHasBadge(player.UserId, BadgeId) then
        tool:Clone().Parent = player:WaitForChild("Backpack")
        else
            print("The user does not have this badge")
    end
end)

This does not work.

local BadgeService = game:GetService("BadgeService")
local BadgeId = 2124743307
local replicatedstorage = game:GetService("ReplicatedStorage")
local tool = replicatedstorage:FindFirstChild("Lucifer")

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        if BadgeService:UserHasBadge(player.UserId, BadgeId) then
            tool:Clone().Parent = player:WaitForChild("Backpack")
        else
        print("The user does not have this badge")
        end
    end)
end)

Thank you for the help in advance, I appreciate it! I'm just here to learn.

1
does it output any errors? sergeant_ranger 184 — 3y
0
There is one output error I forgot to mention. ElBamino 153 — 3y
0
Workspace.Script:13: Expected ')' (to close '(' at line 7), got <eof> - Studio - Script:13 ElBamino 153 — 3y
0
Got it, thanks for the help. I guess I needed a break and to come back to it. Realized what I did wrong, it was simple. ElBamino 153 — 3y

Answer this question