hello, i have a problem where in output is shows Workspace.Wood.Script:13: invalid argument #2 to 'random' (interval is empty)
but script seems fine
wood.Position = Vector3.new(math.random(-157, 249.5), math.random(247, -262.5))
hello, i have a problem where in output is shows Workspace.Wood.Script:13: invalid argument #2 to 'random' (interval is empty)
but script seems fine
wood.Position = Vector3.new(math.random(-157, 249.5), math.random(247, -262.5))
I believe the problem lies in the second math.random
. The first value should be lower than the second, otherwise there is a negative amount of numbers in between them, which causes an error.
Switch them around, and try again.
Found this online for getting random number with decimals, can’t confirm it works though:
(min + 0.5 + math.random() * ( max - min ))
Also, math.random() does not take decimals
i tried to do it, but still no difference
You tried this? Also wouldn’t you want another math.Random for the Z axis?
wood.Position = Vector3.new(math.random(-157, 249), math.random(-263, 247 ))
math.random does not take in decimal thingies, it makes the computer cry. You can get a uniformic value by parsing no parameters then adding that to the whole number with another math.random.
oh i forgot about z, how should i put thescript then?
Try this. Also do you really want the y axis to be that random?
wood.Position = Vector3.new(math.random(-157, 249), math.random(-263, 247 ), math.random(-157, 249))
''Position is not a valid member of Model “Workspace.Wood”
You cannot do the position of a model. If you set a primary part for the model then you could do the following. To set a primary part go to properties of the model and click on primary part, then click on a child of the model.
wood.PrimaryPart = wood.MeshPart
wood:SetPrimaryPartCFrame(CFrame.new(Vector3.new(math.random(-157, 249), math.random(-263, 247 ), math.random(-157, 249))))
“Unable to cast Vector3 to CoordinateFrame”
bruh
oh nvm wait a sec i didnt put primary part
Wait, I incorrectly did the code. Set the primary part and also give me a moment to correct it.
Edit: Alright try it now.
i have another problem i cannot set prim part since that is a tree and there must be 2 parts
What is the name of the trunk or whatever, I can set the primary pat in the script.
the name is just a ‘MeshPart’ but still i must have both parts together
Try it now. I changed the code to set the primary party to “MeshPart”
yes, its working now but height is messed up
What is the height that you want? Just replace the middle math.Random with the desired height.
local Height = 5
wood.PrimaryPart = wood.MeshPart
wood:SetPrimaryPartCFrame(CFrame.new(Vector3.new(math.random(-157, 249),Height, math.random(-157, 249))))
thank you so much, just one little request if you can help