Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why won't this click script work?

Asked by 8 years ago

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

0
It means that the thing called "SpotLight" is not in the hierarchy you put in the script yogipanda123 120 — 8y
0
no, in part it there is ClickDirector, Script, Spotlight, and talk salmonbear242 50 — 8y
0
Use WaitForChild on line 20 like so: local Spotlight = script.Parent:WaitForChild("SpotLight") Spongocardo 1991 — 8y
0
After your answer spongo now output said 18:48:27.682 - Color3 is not a valid member of SpotLight salmonbear242 50 — 8y
View all comments (2 more)
0
Spotlight.Color = Color3.new(255,58,24) You need Color3.new. Use that for the other line. Shawnyg 4330 — 8y
0
Its still not working salmonbear242 50 — 8y

1 answer

Log in to vote
0
Answered by
Rikuzao 20
8 years ago

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

Ad

Answer this question