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

When you buy a tool it gives you negative leaderstats?

Asked by 2 years ago

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

Log in to vote
0
Answered by
SuperPuiu 497 Moderation Voter
2 years ago
Edited 2 years ago

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.

Ad

Answer this question