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: Looking for some help;

Previous Thread :: Next Thread 
TheShoeBox is not online. TheShoeBox
Joined: 20 Aug 2010
Total Posts: 5022
20 Jan 2012 03:56 PM
I wrote this out, it doesn't seem to be working.

Could anyone help me?
If so, that'd be awesome.


x = script.Parent.GenColor

function onClicked()

if x.BrickColor = "Lime green" then
x.BrickColor = "Bright red"
while true do
script.Parent.val.Value + 1
wait(10)
end

elseif x.BrickColor = "Bright red" then
x.BrickColor = "Lime green"
while true do
script.Parent.val.Value + 1
wait(10)
end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)


Nothing on output.
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
20 Jan 2012 04:00 PM
if x.BrickColor == BrickColor.new("Lime green") then

I think...
† KMXD †
Report Abuse
NeonBlox is not online. NeonBlox
Joined: 19 Oct 2008
Total Posts: 1462
20 Jan 2012 04:02 PM
When comparing, use '==' not '='.

if x.BrickColor = "Lime green" then

should be..

if x.BrickColor == "Lime green" then

Do the same for the elseif statement to. I didn't look over it closely, that was the only error that stood out. By the way, what is GenColor?
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
20 Jan 2012 04:04 PM
x.BrickColor is a userdata.
Knightmare's method is correct. Here's an alternative approach:


if tostring(x.BrickColor) == "Lime green" then


OR


if x.BrickColor.name == "Lime green" then
Report Abuse
NeonBlox is not online. NeonBlox
Joined: 19 Oct 2008
Total Posts: 1462
20 Jan 2012 04:04 PM
Use knightmare's, I thought you only needed BrickColor.new("Colour") when you were changing colours, not checking.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
20 Jan 2012 04:07 PM
The only reason the == operator works on BrickColor values is because of the __eq metamethod in each of the BrickColor userdatas. Here's what __eq looks like:


__eq = function(Comp1, Comp2)
    local X = pcall(function() return Comp1.name end)
    local X2 = pcall(function() return Comp2.name end)
    if X and X2 then
        if Comp1.name == Comp2.name then
            return true
        end
    end
    return false
end



The pcalls are there to check if the property name actually exists.
Report Abuse
TheShoeBox is not online. TheShoeBox
Joined: 20 Aug 2010
Total Posts: 5022
20 Jan 2012 04:14 PM
Still doesn't seem to work.


This is what I now have;


x = script.Parent.GenColor

function onClicked()

if x.BrickColor.name == "Lime green" then
x.BrickColor = "Bright red"
while true do
script.Parent.val.Value + 1
wait(10)
end
end
elseif x.BrickColor.name == "Bright red" then
x.BrickColor = "Lime green"
while true do
script.Parent.val.Value + 1
wait(10)
end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
Report Abuse
TheShoeBox is not online. TheShoeBox
Joined: 20 Aug 2010
Total Posts: 5022
20 Jan 2012 04:22 PM
Bump?
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
20 Jan 2012 04:24 PM
Sorry, use capital N. BrickColor.Name
Report Abuse
TheShoeBox is not online. TheShoeBox
Joined: 20 Aug 2010
Total Posts: 5022
20 Jan 2012 04:27 PM
Oh, haha.

I was wondering if that was it, but you wrote it like that.

Thanks!
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
20 Jan 2012 04:32 PM
This also is wrong-

x.BrickColor = "Bright red"

should be...

x.BrickColor = BrickColor.new("Bright red") --need to use BrickColor.new()
Report Abuse
TheShoeBox is not online. TheShoeBox
Joined: 20 Aug 2010
Total Posts: 5022
21 Jan 2012 01:13 PM
Still doesn't seem to be working. Nothing on output:


x = script.Parent.GenColor

function onClicked()

if x.BrickColor.Name == "Lime green" then
x.BrickColor = BrickColor.new("Bright red")
while true do
script.Parent.val.Value + 1
wait(10)
end
elseif x.BrickColor.Name == "Bright red" then
x.BrickColor = BrickColor.new("Lime green")
while true do
script.Parent.val.Value + 1
wait(10)
end
end
end


script.Parent.ClickDetector.MouseClick:connect(onClicked)
Report Abuse
TheShoeBox is not online. TheShoeBox
Joined: 20 Aug 2010
Total Posts: 5022
21 Jan 2012 01:23 PM
Could someone please help?
Report Abuse
ExoCross is not online. ExoCross
Joined: 26 Jan 2011
Total Posts: 179
21 Jan 2012 01:25 PM
Change both "script.Parent.val.Value + 1"
To:

script.Parent.val.Value = script.Parent.val.Value + 1
Report Abuse
TheShoeBox is not online. TheShoeBox
Joined: 20 Aug 2010
Total Posts: 5022
21 Jan 2012 01:30 PM
Didn't fix it.

Is there something wrong with my "ends?"
Report Abuse
ExoCross is not online. ExoCross
Joined: 26 Jan 2011
Total Posts: 179
21 Jan 2012 01:31 PM
Give it another end.
Report Abuse
ExoCross is not online. ExoCross
Joined: 26 Jan 2011
Total Posts: 179
21 Jan 2012 01:32 PM
Eh, nevermind, you have enough. Any output?
Report Abuse
TheShoeBox is not online. TheShoeBox
Joined: 20 Aug 2010
Total Posts: 5022
21 Jan 2012 01:34 PM
Nothing. :|
Report Abuse
TheShoeBox is not online. TheShoeBox
Joined: 20 Aug 2010
Total Posts: 5022
21 Jan 2012 01:49 PM
Bump
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
21 Jan 2012 10:59 PM
I'd suggest comparing BrickColors instead of strings-

if x.BrickColor.Name == "Lime green" then

instead do...

if x.BrickColor == BrickColor.new("Lime green") then
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