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
 

Re: If statement not working!

Previous Thread :: Next Thread 
GamerOfGames123 is not online. GamerOfGames123
Joined: 14 Jul 2012
Total Posts: 210
27 Dec 2013 03:09 PM
Hi! I'm making a place where you have an empire.
I'm trying to make a button gui to place a house, but, when i try to put an if it
get an error!
Script:

local player = script.Parent.Parent.Parent.Parent.Parent
local wood = player.leaderstats.Wood
local stone = player.leaderstats.Stone
script.Parent.BackgroundColor3 = Color3.new(88, 88, 88)
function onClicked()
if stone >= 50 then HERE
local brick = Instance.new("Part", game.Workspace.Buildings)
brick.Name = "NewBrick"
brick.Size = Vector3.new(1, 1, 1)
brick.Position = player.Character.Torso.Position
brick.BrickColor = player.TeamColor
brick.Archivable = false
brick.Anchored = true
script.Parent.BackgroundColor3 = Color3.new(0, 0, 170)
wait(1)
script.Parent.BackgroundColor3 = Color3.new(88, 88, 88)
end
end
script.Parent.MouseButton1Click:connect(onClicked)
Report Abuse
Alex4897 is not online. Alex4897
Joined: 06 Aug 2008
Total Posts: 14517
27 Dec 2013 03:14 PM
Your wood and stone variables need to be player.leaderstats.(material).Value

Your current script is checking if the object stone itself is above or equal to 50. It needs to check the objects value.

I am an eggspert in the eggcelent art of egg puns.
Report Abuse
TheNickmaster21 is not online. TheNickmaster21
Joined: 04 Oct 2008
Total Posts: 9490
27 Dec 2013 03:14 PM
if stone.Value >= 50 then


.Value is important.
Report Abuse
GamerOfGames123 is not online. GamerOfGames123
Joined: 14 Jul 2012
Total Posts: 210
27 Dec 2013 03:19 PM
Thank you! :D
Report Abuse
GamerOfGames123 is not online. GamerOfGames123
Joined: 14 Jul 2012
Total Posts: 210
27 Dec 2013 03:23 PM
Now it isn't placing the brick:
local player = script.Parent.Parent.Parent.Parent.Parent
local wood = player.leaderstats.Wood.Value
local stone = player.leaderstats.Stone.Value
script.Parent.BackgroundColor3 = Color3.new(88, 88, 88)
function onClicked()
if stone >= 50 then
local brick = Instance.new("Part", game.Workspace.Buildings)
brick.Name = "NewBrick"
brick.Size = Vector3.new(1, 1, 1)
brick.Position = player.Character.Torso.Position
brick.BrickColor = player.TeamColor
brick.Archivable = false
brick.Anchored = true
stone = stone - 50
script.Parent.BackgroundColor3 = Color3.new(0, 0, 170)
wait(1)
script.Parent.BackgroundColor3 = Color3.new(88, 88, 88)
else
script.Parent.BackgroundColor3 = Color3.new(170, 0, 0)
wait(1)
script.Parent.BackgroundColor3 = Color3.new(88, 88, 88)
end
end
script.Parent.MouseButton1Click:connect(onClicked)
Report Abuse
Alex4897 is not online. Alex4897
Joined: 06 Aug 2008
Total Posts: 14517
27 Dec 2013 03:24 PM
Do you know where the specific error is?

I am an eggspert in the eggcelent art of egg puns.
Report Abuse
GamerOfGames123 is not online. GamerOfGames123
Joined: 14 Jul 2012
Total Posts: 210
27 Dec 2013 03:48 PM
No, i think is because the if! If i remove the if i can place the brick!
Report Abuse
GamerOfGames123 is not online. GamerOfGames123
Joined: 14 Jul 2012
Total Posts: 210
27 Dec 2013 03:53 PM
Here is my leaderboard (With stone)
game.Players.PlayerAdded:connect(function(player)
-- Leaderstats:
local leaderstats = Instance.new("Model", player)
leaderstats.Name = "leaderstats"
-- Tools:
local lumbertool = Instance.new("BoolValue", player)
lumbertool.Name = "lumbertool"
local minertool = Instance.new("BoolValue", player)
minertool.Name = "minertool"
-- Items/Score:
local wood = Instance.new("IntValue", leaderstats)
wood.Name = "Wood"
wood.Value = 25
local stone = Instance.new("IntValue", leaderstats)
stone.Name = "Stone"
stone.Value = 25
local maxpopulation = Instance.new("IntValue", leaderstats)
maxpopulation.Name = "MaxPopulation"
maxpopulation.Value = 3
local population = Instance.new("IntValue", leaderstats)
population.Name = "Population"
population.Value = 0
end)
Report Abuse
GamerOfGames123 is not online. GamerOfGames123
Joined: 14 Jul 2012
Total Posts: 210
27 Dec 2013 03:59 PM
Go to my place to seed what is happening! I already have send a friend request.
http://www.roblox.com/Empire-Age-Closed-Alpha-V0-03-place?id=140004774
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