So I'm trying to make a random position within a position but it does not seem to be very random The "if magnitude > 15 then" was an attempt to make it come back. No output errors...
force = script.Parent.BodyPosition
local spawn = game.Workspace.Spawn
local x2 = (spawn.Position.x)
local y2 = (spawn.Position.y)
local z2 = (spawn.Position.z)
print(Vector3.new(x2/3, y2, z2/3))
local GyroChance = math.random(1,5)
---print(GyroChance)
if GyroChance == 1 then
if not script.Parent:FindFirstChild("BodyGyro") then
----print("Gyro")
local Gyro = Instance.new("BodyGyro")
Gyro.Parent = script.Parent
end
else
if script.Parent:FindFirstChild("BodyGyro") then
script.Parent:FindFirstChild("BodyGyro"):remove()
end
end
---print(x2,y2,z2)
---local x = (math.random(z2,x2))
---local y = (math.random(y2,y2))
---local z = (math.random(x2,z2))
---print(x,y,z)
while true do
wait(1)
local magnitude = (script.Parent.Position - spawn.Position).magnitude
local x2 = (spawn.Position.x)
local y2 = (spawn.Position.y)
local z2 = (spawn.Position.z)
if magnitude > 15 then
--print("To far!")
force.position = Vector3.new(x2, y2, z2)
else
--print("Just rite")
force.P = math.random(48000,55000)
print(force.P)
local pos1 = Vector3.new(x2,y2,z2)
local pos2 = Vector3.new(x2/2, y2, z2/2)
print(pos2)
local randompos = (math.random(1,2))
if randompos == 1 then
force.position = Vector3.new(pos1)
else
force.position = Vector3.new(pos2)
end
print(force.position)
end
end
