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

How to only allow a model to clone when you have enough currency on your leaderstat?

Asked by 2 years ago

I only have the cloning part and purchasing system done, so it spawns in when you press the text button and it reduces your money. I'm not sure what to add to make it only clone when there is enough currency in the leaderstat. For example, the price is 200 and I only want it to clone only when you have 200 in the leaderstat. The cloning is also set up with a text button so when you press it, the clone happens. So, all i need is the script add ons to make it only happen when you purchase it with enough money.

--My Script:

**local player = game.Players local button = script.Parent

button.MouseButton1Click:Connect(function() ClonedTalent = game.ServerStorage.Talents.Ben:Clone() ClonedTalent.Parent = game.Workspace ClonedTalent.Name = "Talent" end)**

1 answer

Log in to vote
0
Answered by 2 years ago
local button = script.Parent
local gui=button.Parent
local player=gui.Parent.Parent 

button.MouseButton1Click:Connect(function()
if player.leaderstats.Points.Value>=200 then
player.leaderstats.Points.Value-=200

 ClonedTalent = game.ServerStorage.Talents.Ben:Clone() 
ClonedTalent.Parent = game.Workspace 
ClonedTalent.Name = "Talent"


end;end)

Ad

Answer this question