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: Why doesn't this script work?

Previous Thread :: Next Thread 
georgeba is not online. georgeba
Joined: 29 Oct 2011
Total Posts: 1092
11 Nov 2014 07:42 PM
while true do
wait()
if script.Parent.BackgroundColor3 == Color3.new(196, 40, 28) then
script.Parent.Parent.ShieldValue = "Bright red"
elseif
script.Parent.BackgroundColor3 == Color3.new(164, 189, 71) then
script.Parent.Parent.ShieldValue = "Camo"
elseif script.Parent.BackgroundColor3 == Color3.new(218, 133, 65) then
script.Parent.Parent.ShieldValue = "Deep orange"
elseif script.Parent.BackgroundColor3 == Color3.new(245, 205, 48) then
script.Parent.Parent.ShieldValue = "Bright Yellow"
elseif script.Parent.BackgroundColor3 == Color3.new(107, 50, 124) then
script.Parent.Parent.ShieldValue = "Bright violet"
elseif script.Parent.BackgroundColor3 == Color3.new(204, 142, 105) then
script.Parent.Parent.ShieldValue = "Nougat"
end
end






This doesn't seem to work. The shield value is a brick color value.
Report Abuse
Oskee is not online. Oskee
Joined: 24 Jul 2014
Total Posts: 297
11 Nov 2014 07:47 PM
script.Parent.Parent.ShieldValue = "Bright yellow"

u caps yellow
Report Abuse
LizardCar is not online. LizardCar
Joined: 06 Dec 2010
Total Posts: 36
11 Nov 2014 07:58 PM
I don't think you can compare .BackgroundColor3 with Color3.new(v,v,v), also, the Color3.new accepts numbers from 0 to 1 (Color3.new(204/255,142/255,105/255), or Color3.new(0.8,0.56,0.41)).

Maybe you might need to reformat the script using BrickColor.Name
(http://wiki.roblox.com/index.php?title=BrickColor)

Such as

if script.Parent.BackgroundColor3.Name=="Bright red" then
script.Parent.Parent.ShieldValue = "Bright red"
---and so forth
end

I'm not sure though. I just read this right now. I'm testing it and it seems to work for me.
Report Abuse
LizardCar is not online. LizardCar
Joined: 06 Dec 2010
Total Posts: 36
11 Nov 2014 08:09 PM
Sorry I thought script.Parent.BackgroundColor3 was from a Part Instance.
Report Abuse
Vescatur is not online. Vescatur
Joined: 18 Feb 2012
Total Posts: 3426
11 Nov 2014 08:48 PM
Is ShieldValue a color value, or a string value?

if either, it should be:

script.Parent.Parent.ShieldValue.Value = 'Whatever'
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
11 Nov 2014 08:57 PM
OP, You can't compare color values like that.
Report Abuse
georgeba is not online. georgeba
Joined: 29 Oct 2011
Total Posts: 1092
11 Nov 2014 09:33 PM
Here is the updated script: Still doesn't work.


while true do
wait()
if script.Parent.BackgroundColor3 == Color3.new(196, 40, 28) then
script.Parent.Parent.ShieldValue.Value = "Bright red"
elseif
script.Parent.BackgroundColor3 == Color3.new(164, 189, 71) then
script.Parent.Parent.ShieldValue.Value = "Camo"
elseif script.Parent.BackgroundColor3 == Color3.new(218, 133, 65) then
script.Parent.Parent.ShieldValue.Value = "Deep orange"
elseif script.Parent.BackgroundColor3 == Color3.new(245, 205, 48) then
script.Parent.Parent.ShieldValue.Value = "Bright yellow"
elseif script.Parent.BackgroundColor3 == Color3.new(107, 50, 124) then
script.Parent.Parent.ShieldValue.Value = "Bright violet"
elseif script.Parent.BackgroundColor3 == Color3.new(204, 142, 105) then
script.Parent.Parent.ShieldValue.Value = "Nougat"
end
end




Report Abuse
georgeba is not online. georgeba
Joined: 29 Oct 2011
Total Posts: 1092
11 Nov 2014 11:15 PM
bump
Report Abuse
LizardCar is not online. LizardCar
Joined: 06 Dec 2010
Total Posts: 36
11 Nov 2014 11:56 PM
I used the == operator to compare 2 Color3 objects, and it seem to work. They never mentioned it in http://wiki.roblox.com/index.php/Color3 :(. But I think they mentioned in http://wiki.roblox.com/index.php?title=BrickColor (Comparing BrickColors) that you can compare their Color3 values to see if they're equal.


Try this:

if script.Parent.BackgroundColor3 == BrickColor.new("Bright red").Color then --Compare the Color3 object with Color3 object of BrickColor if equal.
script.Parent.Parent.ShieldValue.Value = "Bright red"
elseif script.Parent.BackgroundColor3 == BrickColor.new("Camo").Color then
script.Parent.Parent.ShieldValue.Value = "Camo"
--And so forth.
end
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
12 Nov 2014 12:36 AM
Yeah you can probably compare it, but if the Color3 was added to, and not changed, it's not going to work as expected.
Report Abuse
georgeba is not online. georgeba
Joined: 29 Oct 2011
Total Posts: 1092
12 Nov 2014 09:39 AM
Updated Script: Still doesn't work

while true do
wait()
if script.Parent.BackgroundColor3 == BrickColor.new("Bright red").Color then --Compare the Color3 object with Color3 object of BrickColor if equal.
script.Parent.Parent.ShieldValue.Value = "Bright red"
elseif script.Parent.BackgroundColor3 == BrickColor.new("Camo").Color then
script.Parent.Parent.ShieldValue.Value = "Camo"
if script.Parent.BackgroundColor3 == BrickColor.new("Deep Orange").Color then --Compare the Color3 object with Color3 object of BrickColor if equal.
script.Parent.Parent.ShieldValue.Value = "Deep Orange"
elseif script.Parent.BackgroundColor3 == BrickColor.new("Camo").Color then
script.Parent.Parent.ShieldValue.Value = "Camo"
if script.Parent.BackgroundColor3 == BrickColor.new("Bright yellow").Color then --Compare the Color3 object with Color3 object of BrickColor if equal.
script.Parent.Parent.ShieldValue.Value = "Bright yellow"
elseif script.Parent.BackgroundColor3 == BrickColor.new("Bright violet").Color then
script.Parent.Parent.ShieldValue.Value = "Bright violet"
if script.Parent.BackgroundColor3 == BrickColor.new("Nougat").Color then --Compare the Color3 object with Color3 object of BrickColor if equal.
script.Parent.Parent.ShieldValue.Value = "Nougat"
elseif script.Parent.BackgroundColor3 == BrickColor.new("Br. yellowish green").Color then
script.Parent.Parent.ShieldValue.Value = "Br. yellowish green"
end
end




Report Abuse
georgeba is not online. georgeba
Joined: 29 Oct 2011
Total Posts: 1092
12 Nov 2014 08:27 PM
Bump
Report Abuse
georgeba is not online. georgeba
Joined: 29 Oct 2011
Total Posts: 1092
13 Nov 2014 07:07 PM
Another bump
Report Abuse
HyroadCoder is not online. HyroadCoder
Joined: 15 Jul 2014
Total Posts: 813
13 Nov 2014 07:22 PM
Hai george.

I see your problem, most likely.

If the value is a Brickcolor Value, I think you should do this:

value.Value = BrickColor.new("Color")

Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
13 Nov 2014 07:26 PM
How does a thread containing two frequent scripters and at least three others not point out the problem of creating a Color3 with values greater than 1?
Report Abuse
georgeba is not online. georgeba
Joined: 29 Oct 2011
Total Posts: 1092
14 Nov 2014 12:08 AM
@Hyroad
Still Doesn't Seem to Work. Oh, and Hai. =)

UPDATED CODE:

while true do
wait()
if script.Parent.BackgroundColor3 == BrickColor.new("Bright red").Color then --Compare the Color3 object with Color3 object of BrickColor if equal.
script.Parent.Parent.ShieldValue.Value = BrickColor.new("Bright red")
elseif script.Parent.BackgroundColor3 == BrickColor.new("Camo").Color then
script.Parent.Parent.ShieldValue.Value = "Camo"
if script.Parent.BackgroundColor3 == BrickColor.new("Deep orange").Color then --Compare the Color3 object with Color3 object of BrickColor if equal.
script.Parent.Parent.ShieldValue.Value = BrickColor.new("Deep orange")
elseif script.Parent.BackgroundColor3 == BrickColor.new("Camo").Color then
script.Parent.Parent.ShieldValue.Value = BrickColor.new("Camo")
if script.Parent.BackgroundColor3 == BrickColor.new("Bright yellow").Color then --Compare the Color3 object with Color3 object of BrickColor if equal.
script.Parent.Parent.ShieldValue.Value = BrickColor.new("Bright yellow")
elseif script.Parent.BackgroundColor3 == BrickColor.new("Bright violet").Color then
script.Parent.Parent.ShieldValue.Value = BrickColor.new("Bright violet")
if script.Parent.BackgroundColor3 == BrickColor.new("Nougat").Color then --Compare the Color3 object with Color3 object of BrickColor if equal.
script.Parent.Parent.ShieldValue.Value = BrickColor.new("Nougat")
elseif script.Parent.BackgroundColor3 == BrickColor.new("Br. yellowish green").Color then
script.Parent.Parent.ShieldValue.Value = BrickColor.new("Br. yellowish green")
end
end




Report Abuse
georgeba is not online. georgeba
Joined: 29 Oct 2011
Total Posts: 1092
16 Nov 2014 12:32 PM
Bump
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
16 Nov 2014 12:42 PM
You probably don't want to do division in comparison with two color3s because floating point precision will probably throw you off.

if BrickColor.new(script.Parent.BackgroundColor3) == BrickColor.new("Bright red") then

Try that, that should round "script.Parent.BackgroundColor3" to the nearest color value available with BrickColor, just in case your BackgroundColor3 value wasn't exact or something.
Report Abuse
georgeba is not online. georgeba
Joined: 29 Oct 2011
Total Posts: 1092
16 Nov 2014 06:38 PM
Nope. Doesn't work.
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