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 » Scripters
Home Search
 

Re: Why isn't this working

Previous Thread :: Next Thread 
RPD777 is not online. RPD777
Joined: 31 May 2016
Total Posts: 121
30 Jul 2017 10:21 AM
I have a part which is "Pearl" in color. Therefore if I touch the part it should turn "Deep orange", but when I touch it, it turns "Cyan".

Any help would be greatly appreciated.


-------------------

script.Parent.Touched:connect(function(player)
if script.Parent.BrickColor == "Pearl" then
script.Parent.BrickColor = BrickColor.new("Deep orange")
else
script.Parent.BrickColor = BrickColor.new("Cyan")
end
end)
Report Abuse
LotsOfViolence is not online. LotsOfViolence
Joined: 29 Jun 2011
Total Posts: 8375
30 Jul 2017 10:22 AM
script.Parent.Touched:connect(function(player)
if script.Parent.BrickColor == BrickColor.new("Pearl") then
script.Parent.BrickColor = BrickColor.new("Deep orange")
else
script.Parent.BrickColor = BrickColor.new("Cyan")
end
end)

Maybe?


Report Abuse
LotsOfViolence is not online. LotsOfViolence
Joined: 29 Jun 2011
Total Posts: 8375
30 Jul 2017 10:25 AM
Ah, you can't compare a string value to a BrickColor value I guess.

I tested it out by doing this:

script.Parent.Touched:connect(function(player)
if tostring(script.Parent.BrickColor) == "Pearl" then
print("Hi")
end
end)

and that works, but if you remove tostring it does not work


Report Abuse
RPD777 is not online. RPD777
Joined: 31 May 2016
Total Posts: 121
30 Jul 2017 10:25 AM
Thanks for the reply, but is still doesn't work
Report Abuse
RPD777 is not online. RPD777
Joined: 31 May 2016
Total Posts: 121
30 Jul 2017 10:26 AM
ok, I will try it
Report Abuse
LaeMVP is online. LaeMVP
Joined: 24 Jun 2013
Total Posts: 4416
30 Jul 2017 10:28 AM
script.Parent.Touched:Connect(function(hit)
script.Parent.BrickColor = script.Parent.BrickColor == BrickColor.new("Pearl") and BrickColor.new("Deep orange") or BrickColor.new("Cyan")
end)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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