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

How do I make it where if I have more than the price, it will still give the item?

Asked by 6 years ago
Edited 6 years ago

I am working on a game and it needs a shop, I am using this script.

script.Parent.MouseButton1Click:connect(function()
 local RS = game:GetService("ReplicatedStorage")
 local item =  RS:WaitForChild("Iron Sword")
 local price = 85 -- Change Your Price Here
 local player = game.Players.LocalPlayer
 local stats = player:WaitForChild("leaderstats")

 if stats.SoulFragments.Value == price then -- Change the Money to your Currency Name
  stats.SoulFragments.Value = stats.SoulFragments.Value - price
  local cloned = item:Clone()
  local cloned2 = item:Clone()
  cloned2.Parent = player.Backpack
  cloned.Parent = player.StarterGear
 end
end)

Though, the problem is, if I don't have EXACTLY 85 points, it doesn't give me the item. Is there anything I can do to fix it?

1 answer

Log in to vote
0
Answered by 6 years ago

On line 08, instead of using == (equal to), use >= (greater than or equal to)

0
Yeah, this is what you want to do. Uzuntu 6 — 6y
Ad

Answer this question