#Can't figure out error from using math.random

1 messages · Page 1 of 1 (latest)

thin glacier
#

I'm writing a function which, when called, teleports a player to a part but a random x and z position of the part. I can't figure out what I've done wrong in this code. Output keeps saying ServerScriptService.Rounds:13: invalid argument #2 to 'random' (interval is empty)

Here is my code:

    local players = Players:GetPlayers()
    for i, player in players do
        if not player.Character then continue end
        
        player.Character:PivotTo(destination * CFrame.new(math.random(-destination.Position.X/2, destination.Position.X/2), 0, math.random(-destination.Position.Z/2, destination.Position.Z/2)))
    end
end```

The destination parameter is the part I want the player to teleport to.
rapid kestrel
thin glacier
#

Ahh okay I got it. Thanks for the help.