So I want the lights to turn on and off every second and the script is in a model in replicated storage and when I parent the model into the workspace the script stops working.
here is the script:
local partlight = script.Parent
local spotlight = partlight.Attachment.SpotLight
while true do
wait(1)
partlight.Material = Enum.Material.Neon
spotlight.Enabled = true
wait(1)
partlight.Material = Enum.Material.SmoothPlastic
spotlight.Enabled = false
wait(1)
end
local partlight = workspace:WaitForChild(“YourPartLightName”)
local spotlight = partlight:FindFirstChild(“Attachment”) and partlight.Attachment:FindFirstChild(“SpotLight”)
if partlight and spotlight then
while true do
wait(1)
partlight.Material = Enum.Material.Neon
spotlight.Enabled = true
wait(1)
partlight.Material = Enum.Material.SmoothPlastic
spotlight.Enabled = false
wait(1)
end
else
warn(“Partlight or Spotlight is missing.”)
end
Is your script a LocalScript or a server Script? LocalScripts aren’t able to run inside of Workspace, so if your script is a LocalScript, then there are two methods you can use to fix your problem:
If the code doesn’t need to run on the client-side, and you don’t mind having the server run the code, then replace the LocalScript with a server Script
If the code needs to run on the client, or you don’t want the server to run it, then you’ll still need to replace the LocalScript with a server Script, but make sure that you change the server Script’s RunContext property to Client