Hello devs! Im making a safezone commands for safezone pack and my 2 commands aren’t working
first one - rainbow safezone
local rainbow = false
Commands[Rainbow_SafeZone_Command] = function(admin, safezone, value)
safezone = workspace:FindFirstChild(safezone)
if safezone then
local material = safezone.Material
local color = safezone.Color
if value == "True" or "true" then
rainbow = true
safezone.Material = Enum.Material.Neon
local pointlight = safezone:FindFirstChild("PointLight") or safezone:FindFirstChildOfClass("PointLight")
if not pointlight then
pointlight = Instance.new("PointLight", safezone)
end
while safezone do
task.wait()
if rainbow == true then
local hue = tick() % 10/10
safezone.Color = Color3.fromHSV(hue, 1, 1)
pointlight.Color = Color3.fromHSV(hue, 1, 1)
pointlight.Range = 20
pointlight.Shadows = true
end
if safezone.Material ~= Enum.Material.Neon then
safezone.Material = Enum.Material.Neon
end
end
end
if value == "False" or "false" then
rainbow = false
safezone.Material = material
safezone.Color = color
local pointlight = safezone:FindFirstChild("PointLight") or safezone:FindFirstChildOfClass("PointLight")
if pointlight then
pointlight:Destroy()
end
end
end
end
This script makes safezone color to rainbow or normal
but if i say false, my safezone changes to rainbow color
Second - Resize safezone command
Commands[Change_SafeZoneSize_Command] = function(admin, safezone, x_size, y_size, z_size)
safezone = workspace:FindFirstChild(safezone)
if safezone and typeof(x_size) == "number" and typeof(y_size) == "number" and typeof(z_size) == "number" then
safezone.Size = Vector3.new(x_size, y_size, z_size)
end
if safezone and x_size == "Normal" or y_size == "Normal" or z_size == "Normal" then
safezone.Size = Vector3.new(31, 28, 38)
end
end
the goal was resizing the safezone size but it doesnt work anything
First one. You have a while loop which will prevent the rest of the script from completing. So it never checks for the value arg. Move the while loop to the end of the function.
Second. Not sure, I assume it is failing the logic test somehow, try printing typeOf for the x_size etc
You can also specify type in the function arguments like function myFunc(Val : number) it should throw an error then if it gets the wrong type.
local rainbow = false
local function Rainbow(safezone, pointlight)
while safezone do
task.wait()
if rainbow == true then
local hue = tick() % 10/10
safezone.Color = Color3.fromHSV(hue, 1, 1)
pointlight.Color = Color3.fromHSV(hue, 1, 1)
pointlight.Range = 20
pointlight.Shadows = true
end
if safezone.Material == Enum.Material.Neon then
safezone.Material = Enum.Material.Neon
end
end
end
Commands[Rainbow_SafeZone_Command] = function(admin, safezone, value)
safezone = workspace:FindFirstChild(safezone)
if safezone then
local material = safezone.Material
local color = safezone.Color
if value == "True" or "true" then
rainbow = true
safezone.Material = Enum.Material.Neon
local pointlight = safezone:FindFirstChild("PointLight") or safezone:FindFirstChildOfClass("PointLight")
if not pointlight then
pointlight = Instance.new("PointLight", safezone)
end
spawn(Rainbow(safezone, pointlight))
end
if value == "False" or "false" then
rainbow = false
safezone.Material = material
safezone.Color = color
local pointlight = safezone:FindFirstChild("PointLight") or safezone:FindFirstChildOfClass("PointLight")
if pointlight then
pointlight:Destory()
end
end
end
end
Interesting. Try adding a longer task.wait(0.3) to the loop, it could just be running too fast to work properly.
Do you not have any errors in output otherwise?