So, just I wanted to make a Blackout script with Emergency Power and when I click at the button which calls the function It wont work but if I execute the same command in Studio Command Bar then it works normally.
Button:
local b = require(game.ServerScriptService.Blackout) script.Parent.ClickDetector.MouseClick:Connect(function() b.EmPower("All") end
Module Script:
local Blackout = {} local bulb = 120,150,0 local light = 120,150,0 local normal = 253,253,253 local CDC = workspace.CDC.Lights local LCZ = workspace.LCZ.Lights local MCZ = workspace.MCZ.Lights local HCZ = workspace.HCZ.Lights local EZ = workspace.EZ.Lights --//Important\\-- Blackout.StatusLCZ = false Blackout.StatusMCZ = false Blackout.StatusHCZ = false Blackout.StatusEZ = false --//Scripting\\-- Blackout.EmPower = function(section) if section == "All" then FullEmPower() elseif section == "LCZ" then LCZEmPower() elseif section == "MCZ" then MCZEmPower() elseif section == "HCZ" then HCZEmPower() end end Blackout.Blackout = function(section) if section == "All" then FullBlackout() Blackout.StatusLCZ = true Blackout.StatusMCZ = true Blackout.StatusHCZ = true elseif section == "LCZ" then LCZBlackout() Blackout.StatusLCZ = true elseif section == "MCZ" then MCZBlackout() Blackout.StatusMCZ = true elseif section == "HCZ" then HCZBlackout() Blackout.StatusHCZ = true end end Blackout.PowerUp = function() print("Powering up..") for i,v in pairs(LCZ:GetChildren()) do v.Part.EmPower.Enabled = false v.Part.PointLight.Enabled = true v["Fake Light"].Light.BrickColor = BrickColor.new("Mid gray") v["Fake Light"].Light.Transparency = 0 v["Fake Light"].EmLight.Transparency = 1 end for i,v in pairs(CDC:GetChildren()) do v.Part.EmPower.Enabled = false v.Part.PointLight.Enabled = true v["Fake Light"].Light.BrickColor = BrickColor.new("Mid gray") v["Fake Light"].Light.Transparency = 0 v["Fake Light"].EmLight.Transparency = 1 end for i,v in pairs(MCZ:GetChildren()) do v.Part.EmPower.Enabled = false v.Part.PointLight.Enabled = true v["Fake Light"].Light.BrickColor = BrickColor.new("Mid gray") v["Fake Light"].Light.Transparency = 0 v["Fake Light"].EmLight.Transparency = 1 end for i,v in pairs(HCZ:GetChildren()) do v.Part.EmPower.Enabled = false v.Part.PointLight.Enabled = true v["Fake Light"].Light.BrickColor = BrickColor.new("Mid gray") v["Fake Light"].Light.Transparency = 0 v["Fake Light"].EmLight.Transparency = 1 end Blackout.StatusLCZ = false Blackout.StatusMCZ = false Blackout.StatusHCZ = false workspace.Music.Alarms.EmPowerBeeb:Stop() print("POWERED!") end --//Functions\\-- function FullBlackout() LCZBlackout() MCZBlackout() HCZBlackout() Blackout.StatusLCZ = true Blackout.StatusMCZ = true Blackout.StatusHCZ = true end function FullEmPower() print("EMEPOWER") LCZEmPower() MCZEmPower() HCZEmPower() workspace.Music.Alarms.EmPower:Play() end function LCZBlackout() for i,v in pairs(LCZ:GetChildren()) do v.Part.PointLight.Enabled = false v["Fake Light"].Light.BrickColor = BrickColor.new("Really black") end for i,v in pairs(CDC:GetChildren()) do v.Part.PointLight.Enabled = false v["Fake Light"].Light.BrickColor = BrickColor.new("Really black") end end function LCZEmPower() if Blackout.StatusLCZ == true then for i,v in pairs(LCZ:GetChildren()) do v.Part.EmPower.Enabled = true v["Fake Light"].Light.Transparency = 1 v["Fake Light"].EmLight.Transparency = 0 end end end function MCZBlackout() for i,v in pairs(MCZ:GetChildren()) do v.Part.PointLight.Enabled = false v["Fake Light"].Light.BrickColor = BrickColor.new("Really black") end end function MCZEmPower() if Blackout.StatusMCZ == true then for i,v in pairs(MCZ:GetChildren()) do v.Part.EmPower.Enabled = true v["Fake Light"].Light.Transparency = 1 v["Fake Light"].EmLight.Transparency = 0 end end end function HCZBlackout() for i,v in pairs(HCZ:GetChildren()) do v.Part.PointLight.Enabled = false v["Fake Light"].Light.BrickColor = BrickColor.new("Really black") end end function HCZEmPower() if Blackout.StatusHCZ == true then for i,v in pairs(HCZ:GetChildren()) do v.Part.EmPower.Enabled = true v["Fake Light"].Light.Transparency = 1 v["Fake Light"].EmLight.Transparency = 0 end end end return Blackout --[[for i,v in pairs(LCZ:GetChildren()) do v.Part.EmPower.Enabled = true v["Fake Light"].Light.Transparency = 1 v["Fake Light"].EmLight.Transparency = 0 end]]
Sorry for formating lol it broke.. I just really don't know where is the mistake or something.. (Button Script is ServerScript)
In the server script, The first script you just gave us you forgot to add a bracket at the end
Your code:
local b= require(game.ServerScriptService.Blackout)
script.Parent.ClickDetector.MouseClick:Connect(function()
b.EmPower("All")
end
It should be;
Code:
local b= require(game.ServerScriptService.Blackout)
script.Parent.ClickDetector.MouseClick:Connect(function()
b.EmPower("All")
end)
The error should've been in your output box, If you don't have it enabled i recommend you to enable it.
Hope This Helped.