Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Change Color Script issue. Why is it not working? I would really like help.

Here is the script

game.Workspace.Light.SpotLight.Color3.new(255, 0, 0)

Yes it runs it. Here is the full script. I only need help with this bit tho.

Code = "412"
button = script.Parent.Parent.Enter
function Enter()
if (script.Parent.Text == Code) then
print("Accepted")
script.Parent.Text = "Lockdown Actived!"
script.Parent.Parent.Sound2:play()
wait(0.5)
script.Parent.Text = "Have a nice day"

game.Workspace.LockdownWarning:Play()
wait(19)
game.Workspace.LockdownMusic:Play()
game.Workspace.Light.SpotLight.Color3.new(255, 0, 0)


return end
script.Parent.TextColor3 = Color3.new(1,0,0)
wait(0.1)
script.Parent.TextColor3 = Color3.new(1,1,1)
wait(0.1)
script.Parent.TextColor3 = Color3.new(1,0,0)
wait(0.1)
script.Parent.TextColor3 = Color3.new(1,1,1)
wait(0.1)
script.Parent.TextColor3 = Color3.new(1,0,0)
wait(0.1)
script.Parent.TextColor3 = Color3.new(1,1,1)
wait(0.1)
script.Parent.Text = "Acces Denied"
script.Parent.Parent.Sound3:play()
wait(0.1)
script.Parent.Parent.Sound3:play()
script.Parent.TextColor3 = Color3.new(1,0,0)
wait(0.5)
script.Parent.TextColor3 = Color3.new(1,1,1)
script.Parent.Text = ""
print("Denied")
end

button.MouseButton1Click:connect(Enter)

3 answers

✓ Accepted answer

First of all starting with this line, game.Workspace.Light.SpotLight.Color3.new(255, 0, 0), that's not how you set a property of an object. Second of all, the Color3 constructor takes three arguments from 0 to 1. If you want to construct a Color3 using RGB values, use Color3.fromRGB(R,G,B). With these corrections, the line should look like so.

game.Workspace.Light.SpotLight.Color = Color3.fromRGB(255, 0, 0)

You did this:

game.Workspace.Light.SpotLight.Color3.new(255,0,0) -- That won't work

but color3 stores as 0-1 value, try this:

game.Workspace.Light.SpotLight.Color3.new(1, 0, 0)

or this...

game.Workspace.Light.SpotLight.Color3.fromRGB(255,0,0)

2 comments

0

that still won't work...

0

@creeperhunter76, I tried and it works, can you explain why it didn't work?

Ah. It is working i think. If the other solutions don't work, the color has changed but the light isnt visible.

This discussion is preserved as it was. New answers, comments, and votes are closed.