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

How to prevent tools from cloning itself?

Asked by 5 years ago

I'm trying to make a hotel game. Ran into this glitch where the 'Staff Card' clones itself for some reason. I've looked everywhere in the game and I've yet to find the cause for it. Here's the script that gives the player the card. I would really appreciate it if someone found out. Thanks again!

game.Workspace.ChildAdded:connect(function(child)
    if game.Players:GetPlayerFromCharacter(child) then
        local player = game.Players:GetPlayerFromCharacter(child)
        if player:GetRankInGroup(script.GroupID.Value) >= script.RankID.Value then
            local ckey = game.ServerStorage["Staff Card"]:Clone()
            ckey.Parent = player.Backpack
        end
    end
end)
print("The Staff Card has been added to your inventory.")
0
The print is in the wrong place btw. It should be with the clone script, not outside of it Tweakified 117 — 5y

1 answer

Log in to vote
0
Answered by
OnaKat 444 Moderation Voter
5 years ago
game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function()
        if player:GetRankInGroup(script.GroupID.Value) >= script.RankID.Value then
            local ckey = game.ServerStorage["Staff Card"]:Clone()
            ckey.Parent = player.Backpack
        end
    end)
end)
print("The Staff Card has been added to your inventory.")
Ad

Answer this question