I've set up a script so that players randomly spawn within an area, but for some reason, I always spawn right outside of the area I have scripted to spawn inside. Could anyone help me fix this issue?
Here is my script:
while true do
wait(30)
local m = math.random(1, 3)
local player = game.Players:GetPlayers()
for i = 1, #player do
msg = Instance.new("Message")
msg.Parent = nil
if m == 1 then
msg.Parent = game.Workspace
msg.Text = "Scattered Blocks"
wait(5)
player[i].Character:MoveTo(Vector3.new(math.random(1, 199), 50, math.random(1, 199)))
msg:remove()
wait(60)
g = game.Players:GetChildren()
for i = 1, #g do
if g[i]:IsA("Player")
then
g[i]:LoadCharacter()
end
end
end
if m == 2 then
msg.Parent = game.Workspace
msg.Text = "Truss Platforms"
wait(5)
player[i].Character:MoveTo(Vector3.new(math.random(2, 199), 50, math.random(301, 499)))
msg:remove()
wait(60)
g = game.Players:GetChildren()
for i = 1, #g do
if g[i]:IsA("Player")
then
g[i]:LoadCharacter()
end
end
end
if m == 3 then
msg.Parent = game.Workspace
msg.Text = "Ghost Plate"
wait(5)
player[i].Character:MoveTo(Vector3.new(math.random(1, 199), 50, math.random(601, 799)))
msg:remove()
wait(60)
g = game.Players:GetChildren()
for i = 1, #g do
if g[i]:IsA("Player")
then
g[i]:LoadCharacter()
end
end
end
end
end
|