|
| 22 Aug 2014 10:33 AM |
In my game, i have been trying to create a shop with buy buttons and they dont seem to work properly. Say i have no points, and i walk on the button. I will recieve the item and have -250 points. Can somone please help me? Here is some of my scripting.
Leaderstats
function CreateStats(NewPlayer) local MainStats = Instance.new("IntValue") MainStats.Name = "leaderstats" MainStats.Value = 0 local PointsValue = Instance.new("IntValue") PointsValue.Name = "Points" PointsValue.Value = 0 PointsValue.Parent = MainStats MainStats.Parent = NewPlayer local WinsValue = Instance.new("IntValue") WinsValue.Name = "Wins" WinsValue.Value = 0 WinsValue.Parent = MainStats MainStats.Parent = NewPlayer end
And the button
script.Parent.Touched:connect(function(part) p = game.Players:GetPlayerFromCharacter(part.Parent) if p == nil then return end PumpkinPi = game.ServerStorage.PumpkinPi:clone() if p.Backpack:FindFirstChild(PumpkinPi.Name) ~= nil then return end PumpkinPi.Parent = p.Backpack p:FindFirstChild("leaderstats").Points.Value = p.leaderstats.Points.Value - 250 end)
Can somone please show me how to make this so if the players points is exactly same with the "price" or bigger it will buy it. And show me where it is wrong. |
|
|
| Report Abuse |
|
|
ForceSky
|
  |
| Joined: 30 Jul 2012 |
| Total Posts: 2379 |
|
|
| 22 Aug 2014 11:39 AM |
make a variable that holds the price of the object.
use an if statement.
If PLAYERMONEY >= COST then |
|
|
| Report Abuse |
|
|
|
| 22 Aug 2014 11:57 AM |
script.Parent.Touched:connect(function(part) p = game.Players:GetPlayerFromCharacter(part.Parent) if p == nil then return end PumpkinPi = game.ServerStorage.PumpkinPi:clone() if p.Backpack:FindFirstChild(PumpkinPi.Name) ~= nil then return end PumpkinPi.Parent = p.Backpack if stats.Points.Value >= 250 then p:FindFirstChild("leaderstats").Points.Value = p.leaderstats.Points.Value - 250 end end) so ive done that and now it isent deducting any points so confused |
|
|
| Report Abuse |
|
|