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

Help with player only being able to get the same weapon once?

I am wanting the player to have that same weapon only one time, so they can't get it again once they have it. But with the script posted, they can get a bunch ;(

Price = 5
Player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()
	if Player:FindFirstChild("leaderstats") and Player.leaderstats["Gold bars"].Value >= Price then
		Player.leaderstats["Gold bars"].Value = Player.leaderstats["Gold bars"].Value - Price
		local SpeedCoil = game.ServerStorage.Weapons.SpeedCoil
		SpeedCoil:Clone().Parent = Player.Backpack
		SpeedCoil:Clone().Parent = Player.StarterGear
		
	end
end)

1 answer

✓ Accepted answer

four little lines (and a bool value added to the item)

Price = 5
Player = game.Players.LocalPlayer
local Item = game.ServerStorage.Weapons.SpeedCoil
local Taken = Item.Taken

script.Parent.MouseButton1Click:connect(function()
    if Player:FindFirstChild("leaderstats") and Player.leaderstats["Gold bars"].Value >= Price then
if Taken.Value == false then
        Player.leaderstats["Gold bars"].Value = Player.leaderstats["Gold bars"].Value - Price
        local SpeedCoil = game.ServerStorage.Weapons.SpeedCoil
        SpeedCoil:Clone().Parent = Player.Backpack
        SpeedCoil:Clone().Parent = Player.StarterGear
Taken.Value = true

    end
end)

i tested it by removing your price, and leaderstats script, and it worked so here's that script

Player = game.Players.LocalPlayer

local Item = game.ServerStorage.Weapons.SpeedCoil
local Taken = Item.Taken

script.Parent.MouseButton1Click:connect(function()
    

if Taken.Value == false then


	 local SpeedCoil = game.ServerStorage.Weapons.SpeedCoil
        SpeedCoil:Clone().Parent = Player.Backpack
        SpeedCoil:Clone().Parent = Player.StarterGear
Taken.Value = true

end
end)
       

good luck

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