Here is my math.random:
math.random(h-v, h+v)
Both are integers, and positive numbers. According to the wiki, this should work. Help please?
local Type=1 height=50 variation=10 speed=15 direction="z" local Top=Workspace.TopLimit local Bottom=Workspace.BottomLimit ---------- Function Setup ----------- function place(name) if script:FindFirstChild(name) then script:FindFirstChild(name).Parent=Game.ServerStorage end end function Cloud(s, h, v, d) local dir local c=Game.ServerStorage:FindFirstChild("Cloud"..Type) if d=="x" or d=="-x" then dir=c.XSpeed if d=="x"then dir.Value=s elseif dir.Value=="-x" then dir.Value=0-s end elseif d=="z" or d=="-z" then dir=c.ZSpeed if d=="z"then dir.Value=s elseif dir.Value=="-z" then dir.Value=0-s end end local high=math.random(h-v, h+v) if Top.Position.X>Bottom.Position.X then local ex=math.random(Top.Position.X, Bottom.Position.X) else local ex=math.random(Bottom.Position.X, Top.Position.X) end if Top.Position.Z>Bottom.Position.Z then local zee=math.random(Top.Position.Z, Bottom.Position.Z) else local zee=math.random(Bottom.Position.Z, Top.Position.Z) end c.Destroy.Disabled=false c.SpeedScript.Disabled=false end function Make() Cloud(speed, height, variation, direction) end ----------- Move Assets ------------ local TestMode=false if not TestMode then for i=1, 5 do place("Cloud"..i) end end Workspace.MakeCloud.OnServerEvent:connect(Make) ----------- Main Script ------------ for i=1, frequency do Make() end
You never defined the variables correctly h = height v = variation s = speed
So, you were correct using math.random
, just didn't use it the right way.