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

How to avoid mass duplicate tools for this script and only give when required?

Asked by
TechModel 118
3 years ago
Edited 3 years ago

How do I make it so if it finds "TechModel" have the tool, then it won't execute the script again because I get duplicates sometimes when I reset? If I don't have the tool, then it passes through and gives me the tools.

I did try

if players[i] == plr.Name and plr.BackPack("tool") then return

but it doesn't sound right and doesn't make sense.

local players = {"TechModel"}
local tool = script["The Rocket"]
local car = script.LimboJimbo

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(chr)
        for i = 1, #players do
            if players[i] == plr.Name then
                tool:Clone().Parent = plr:WaitForChild("Backpack")
                LimboJimbo:Clone().Parent = plr:WaitForChild("Backpack")
            end
        end
    end)
end)

1 answer

Log in to vote
1
Answered by 3 years ago

Are you giving these tools to every player? If so, why aren’t you choosing to put the tools in the Starterpack? Just trying to clarify the situation.

But you are right, the issue is occurring after line 08. You need to check that the tools exists by their name and if they do not and the value isn’t nil, then clone. I’m waiting on an answer to a similar question about accessing the properties of tools when in use by a player.

0
This is just like for owner tool only given to me. TechModel 118 — 3y
Ad

Answer this question