I'm making a doll that its head will glow when you left click, but also stops when you left click again. Here's what I've got thus far:

local LightUpDoll = script.Parent
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
lightOn = false

 
local function onActivate(mouse)
	if lightOn == false then
		lightOn = true
		workspace["Light-Up Doll"].Head.SurfaceLight.Enabled = true
		workspace["Light-Up Doll"].Head.Color = "InstitutionalWhite"
		workspace["Light-Up Doll"].Head.Material = "Neon"
	end
	
	if lightOn == true then
		lightOn = false
		workspace["Light-Up Doll"].Head.SurfaceLight.Enabled = false
		workspace["Light-Up Doll"].Head.Color = "BrightYellow"
		workspace["Light-Up Doll"].Head.Material = "SmoothPlastic"
	end
end
 
LightUpDoll.Activated:connect(onActivate)

EDIT: I guess I forgot to mention this earlier, but I cannot get the click function to work. Is there anything I'm missing here, or do I need to rewrite it again?

3 comments

0

Well what do you need help with? Does it work? Btw, I would add a point light and combine the two if statements with and if-else statement

0

once you know the gear is active, connect to the Button1Down event of the mouse and use that to activate the toggle