generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Need help with script

Previous Thread :: Next Thread 
ThePenguinShyBorg is not online. ThePenguinShyBorg
Joined: 17 Aug 2014
Total Posts: 15
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 is not online. 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
ThePenguinShyBorg is not online. ThePenguinShyBorg
Joined: 17 Aug 2014
Total Posts: 15
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image