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

Why won't this click script work?

In this script I'm trying to have a brick clicked and change color, but on output it said that Spotlight is not a valid member of Part

local isOn = false
local talk = script.Parent.talk
function on()
	isOn = true	
	talk.Value = true
end

function off()
	isOn = false	
	talk.Value = false
end

function onClicked()
 
 if isOn == true then off() else on() end

end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
local Spotlight = script.Parent.SpotLight
if isOn == true then Spotlight.Color = 255,58,24
end
if isOn == true then Spotlight.Color = 0,0,255
end

This is what the Part looks like

Part ClickDirector Script Spotlight talk

6 comments

0

It means that the thing called "SpotLight" is not in the hierarchy you put in the script

0

no, in part it there is ClickDirector, Script, Spotlight, and talk

0

Use WaitForChild on line 20 like so: local Spotlight = script.Parent:WaitForChild("SpotLight")

0

After your answer spongo now output said 18:48:27.682 - Color3 is not a valid member of SpotLight

0

Spotlight.Color = Color3.new(255,58,24) You need Color3.new. Use that for the other line.

0

Its still not working

1 answer

✓ Accepted answer

Try watching PeasFactory, he'll have the simple one. This script is too much unnessecary codes... Watch his videos, he'll help alot!

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