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

How do you stop this script from giving you like a thousand items?

local player = script.Parent.Parent
local backpack = player.Backpack

if player.leaderstats then
	while true do
		wait(1)
		if player.leaderstats.Streak.Value == 5 then
			game.ReplicatedStorage.minigun:clone().Parent = backpack
		end
		if player.leaderstats.Streak.Value == 10 then
			game.ReplicatedStorage.AC130:clone().Parent = backpack
		end
	end
end

the script is placed on the starterpack

1 answer

✓ Accepted answer

You have nothing checking if the player already has the tool, here is what you can use:

local player = script.Parent.Parent
local backpack = player.Backpack

player.CharacterAdded:connect(function() -- Wait for the caracter to load
    if player:FindFirstChild("leaderstats") then -- Check for the leaderstats
        while wait() do -- Create a loop
            if player:FindFirstChild("leaderstats").Streak.Value >= 5 and backpack:FindFirstChild("minigun") == nil then -- Check for the streak and if they don't have the minigun
                game.ReplicatedStorage:FindFirstChild("minigun"):Clone().Parent = backpack -- Give the player the minigun
            end
            if player:FindFirstChild("leaderstats").Streak.Value >= 10 and backpack:FindFirstChild("AC130") == nil then -- Check for the streak and if they don't have the 
                game.ReplicatedStorage:FindFirstChild("AC130"):Clone().Parent = backpack -- Give the player the AC130
            end
        end
    end
end

If this worked please vote up and accept as answer!

~ Aaron

1 comment

0

The "and not" isn't working.

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