I was coding something for some guy. He doesn't know how to script, so I decided to give him my services. However, with this generator model, I put the broken version in ReplicatedStorage and the fixed version in Workspace. it worked, until I put fog and ambience configs and settings in. Code here.
Fix code
local ClickDetector = script.Parent.ClickDetector -- The Detector for when the player clicks. Recommended to stay as it is. local printText = "Remote event fired successfully!" -- Put the print text here, when the buttons are fired they will print this text in the Developer Console local brokenAmbient = "0,0,0" -- Put the RGB color of the ambient you've choosed when the generator is broken\ local brokenFogEnd = 350 -- The fog when it is broken local brokenBrightness = 0 -- Change this brightness to your choosing when the generator is broken. local fixedAmbient = "255,255,255" -- Put the RGB color of the fixed ambient/your default ambient local fixedBrightness = 1 -- Change this brightness to your choosing when the generator is fixed/default. local fixedFogEnd = 750 -- The fog when it is fixed local ReplicatedStorage = game:GetService("ReplicatedStorage") -- Replicated storage local GeneratorFolder = game:GetService("Workspace").Generators local Fixed = GeneratorFolder:WaitForChild("Fixed") -- The fixed generator local Broken = ReplicatedStorage:WaitForChild("Broken") -- The broken generator local LeverSound = script.Parent:WaitForChild("LeverPulled") -- When the lever is pressed it will play a lever pulling sound local SoundBroken = script.Parent:WaitForChild("PowerFailure") -- When the red button is pressed this will play local SoundFixed = script.Parent:WaitForChild("PowerFixed") -- When the green button is pressed this will play local SoundDeny = script.Parent:WaitForChild("AccessDenied") -- If the brickcolor that isn't allowed to break it presses the lever, it will play this local MetalHolder = script.Parent.Parent["Metal thing"] -- The metalholder local Circle = script.Parent.Parent["Circle thing"] -- The weird thing thats red local RemoteEvent = game.ReplicatedStorage:WaitForChild("450GKDGKC") -- The remote event to stop exploiters from exploiting the game so easily. local TeamColorBreak = "Institutional white" -- Put the teamcolor here that is allowed to break the machine. function onClick(plr) if plr and plr.TeamColor == BrickColor.new(TeamColorBreak) then RemoteEvent:FireAllClients() print(printText) LeverSound:Play() wait(0.5) SoundDeny:Play() else game.Lighting.FogEnd = fixedFogEnd game.Lighting.Brightness = fixedBrightness game.Lighting.Ambient = Color3.fromRGB(fixedAmbient) RemoteEvent:FireAllClients() print(printText) LeverSound:Play() wait(0.5) SoundFixed:Play() Fixed.Parent = GeneratorFolder Broken.Parent = ReplicatedStorage ClickDetector.MaxActivationDistance = 0 script.Parent.Parent.Parent.Lever.Hitbox.ClickDetector.MaxActivationDistance = 4 end end ClickDetector.MouseClick:Connect(onClick)
Broken:
local ClickDetector = script.Parent.ClickDetector -- The Detector for when the player clicks. Recommended to stay as it is. local printText = "Remote event fired successfully!" -- Put the print text here, when the buttons are fired they will print this text in the Developer Console local brokenAmbient = "0,0,0" -- Put the RGB color of the ambient you've choosed when the generator is broken\ local brokenFogEnd = 350 -- The fog when it is broken local brokenBrightness = 0 -- Change this brightness to your choosing when the generator is broken. local fixedAmbient = "255,255,255" -- Put the RGB color of the fixed ambient/your default ambient local fixedBrightness = 1 -- Change this brightness to your choosing when the generator is fixed/default. local fixedFogEnd = 750 -- The fog when it is fixed local ReplicatedStorage = game:GetService("ReplicatedStorage") -- Replicated storage local GeneratorFolder = game:GetService("Workspace").Generators local Fixed = GeneratorFolder:WaitForChild("Fixed") -- The fixed generator local Broken = ReplicatedStorage:WaitForChild("Broken") -- The broken generator local LeverSound = script.Parent:WaitForChild("LeverPulled") -- When the lever is pressed it will play a lever pulling sound local SoundBroken = script.Parent:WaitForChild("PowerFailure") -- When the red button is pressed this will play local SoundFixed = script.Parent:WaitForChild("PowerFixed") -- When the green button is pressed this will play local SoundDeny = script.Parent:WaitForChild("AccessDenied") -- If the brickcolor that isn't allowed to break it presses the lever, it will play this local MetalHolder = script.Parent.Parent["Metal thing"] -- The metalholder local Circle = script.Parent.Parent["Circle thing"] -- The weird thing thats red local RemoteEvent = game.ReplicatedStorage:WaitForChild("450GKDGKC") -- The remote event to stop exploiters from exploiting the game so easily. local TeamColorBreak = "Institutional white" -- Put the teamcolor here that is allowed to break the machine. function onClick(plr) if plr and plr.TeamColor == BrickColor.new(TeamColorBreak) or plr.Name == "Simpoxus" or "mord3chai" or "Froggy_Fellow" then game.Lighting.FogEnd = brokenFogEnd game.Lighting.Brightness = brokenBrightness game.Lighting.Ambient = Color3.fromRGB(brokenAmbient) RemoteEvent:FireAllClients() print(printText) LeverSound:Play() wait(0.5) SoundBroken:Play() Fixed.Parent = ReplicatedStorage Broken.Parent = GeneratorFolder ClickDetector.MaxActivationDistance = 0 script.Parent.Parent.Parent.Lever2.Hitbox.ClickDetector.MaxActivationDistance = 4 else RemoteEvent:FireAllClients() print(printText) LeverSound:Play() wait(0.5) SoundDeny:Play() end end ClickDetector.MouseClick:Connect(onClick)
**It's really odd, and I don't know why the fog and ambience stays the same after I press the fix lever.
Once again, thanks!**
Update 1: I noticed this only happened in his game, not mine which is really weird.