#Why Wont this Random Offset Code work man please someone help ;-;

1 messages · Page 1 of 1 (latest)

frosty loom
#

local t1a = math.random(-360, -366)
local t1b = math.random(50, 54)
local t1c = math.random(269, 275)

local TelePos1 = {
    Position = CFrame.new(t1a, t1b, t1c)
}

for _, player in ipairs(Players:GetPlayers()) do
    if table.find(GamePlayersRegistered, player) then
        player.Character:WaitForChild("HumanoidRootPart").CFrame = TelePos1.Position
        print("Players Teleported")
        print(TelePos1.Position)
    else
        print("Players not Teleported")
    end
end
true eagle
#

@frosty loom if this is roblox don't use ipairs or pairs because if you use the wrong one it stops your whole code and I think your supposed to used pairs not I pairs due to I standing for index what is for arrays

frosty loom
true eagle
true eagle
true eagle
#

or take them off

frosty loom
#

also uh the error in here ServerScriptService.Main Script:425: invalid argument #2 to 'random' (interval is empty) - Server - Main Script:425 line 425

#

with t1a variable

true eagle
#

I think it's minimum then max

#

-366, -360

#

@frosty loom

frosty loom
#

im genuinely the stupidest person in existance

true eagle
true eagle
frosty loom
#

also what would happen if i removed ipairs and pairs in all my for loops?

true eagle
#

if it's in roblox

frosty loom
#

also yep working also what does this mean here? -364, 52, 272, 1, 0, 0, 0, 1, 0, 0, 0, 1 - Server - Main Script:437

shell veldt
#

You need ipairs

true eagle
#

yh ipairs or none

true eagle
#

also make multiple scripts

#

437 lines is alot

#

add stuff in modules

shell veldt
true eagle
shell veldt
iron hazel
#

local Players = game:GetService("Players")

-- Position aléatoire définie dans une plage donnée
local t1a = math.random(-366, -360)
local t1b = math.random(50, 54)
local t1c = math.random(269, 275)

local TelePos1 = CFrame.new(t1a, t1b, t1c)

-- Vérifie que GamePlayersRegistered est bien défini (table des joueurs concernés)
for _, player in ipairs(Players:GetPlayers()) do
if table.find(GamePlayersRegistered, player) then
local character = player.Character
if character and character:FindFirstChild("HumanoidRootPart") then
character.HumanoidRootPart.CFrame = TelePos1
print(player.Name .. " teleported to " .. tostring(TelePos1))
else
print(player.Name .. " has no valid character or HumanoidRootPart")
end
else
print(player.Name .. " not in registered players list")
end
end

frosty loom
frosty loom