ison = false

humanname = script.Parent.Parent.Parent.Parent.Parent.Name
veh = game.Workspace:FindFirstChild(humanname).PoliceTahoe

function on()
ison = true

local children = veh.PT:GetChildren()
for i=1, #children do
if children[i].Name == "Light" then
children[i].Material = ("Neon")

local children = veh.PT:GetChildren()
for i=1, #children do
if children[i].Name == "NightLight" then
children[i].SpotLight.Enabled = true


function off()
ison = false

local children = veh.PT:GetChildren()
for i=1, #children do
if children[i].Name == "Light" then
children[i].Material = ("Plastic")

local children = veh.PT:GetChildren()
for i=1, #children do
if children[i].Name == "NightLight" then
children[i].SpotLight.Enabled = false

function toggle()
if ison == true then off() else on() end
end


									end
								end
							end
						end
					end
				end
			end
		end
	end
end

script.Parent.MouseButton1Click:connect(toggle) 

So above is my script, and when I run it, the output tells me that "toggle" is not a function. How do I fix this?

1 comment

0

I can't even tell what I'm looking at... Please adjust your code with end in the correct spot along with the correct tabs.