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

When you buy a tool it gives you negative leaderstats?

So when you click a button then you get a tool in your backpack only if you have 15 levels in the leaderstats and it takes away 15 levels from you but instead it takes away like a lot of levels and it gives you a negative value here is my script:

script.Parent.ClickDetector.MouseClick:Connect(function(player) local playerLevel = player.leaderstats.Level playerLevel.Value = playerLevel.Value + 1

if playerLevel.Value >= 15 then
	local ReplicatedStorage = game:GetService("ReplicatedStorage")
	local ToolGiver = game.Workspace.ToolGiver
	local PartTool = game.ReplicatedStorage.PartTool
	ToolGiver.ClickDetector.MouseClick:Connect(function()
		PartTool:Clone()
		PartTool.Parent = player.Backpack
		playerLevel.Value = playerLevel.Value - 15
	end)
end

end)

1 answer

✓ Accepted answer

Maybe change this:

ToolGiver.ClickDetector.MouseClick:Connect(function() 

PartTool:Clone() 
PartTool.Parent = player.Backpack 
playerLevel.Value = playerLevel.Value - 15 

end)

To this:

ToolGiver.ClickDetector.MouseClick:Connect(function() 
if playerLevel.Value >= 15 then
PartTool:Clone() 

PartTool.Parent = player.Backpack 
playerLevel.Value = playerLevel.Value - 15 
      end
end)

It should work.

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