Invalid argument #1 to 'random' (number expected, got CFrame)

Hello
Im quite addicted to undertale and stuff so i making a game about it
the thing is, i tried to make a random position for the “souls”, and what i got was
invalid argument #1 to ‘random’ (number expected, got CFrame)
the script itself


the issue happens at the lines with “CFrame.new = math.random(coordinate,coordinate2)”
i am not really skilled at scripting so how do i fix the issue?

When you say math.random(coordinate, coordinate2), you’re asking for a random number between two non-numbers. This is the error. Also, part.CFrame.new = doesn’t make sense, use part.CFrame = instead.

1 Like
dt.CFrame = CFrame.new() -- whatever here

You had it correct at the top of your script, what are you doing?

1 Like

Also, to remind you, this is an incorrect use of math.random as math.random only returns Integers, use Random.new():NextNumber() to have decimals.

2 Likes

alright thanks, gonna try it out

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.