I want to teleport parts inside of a big part randomly and that the parts can’t go outside of the big part on the x and z axis but it can on the y. And it starts at the bottom and works its way up. For example, in Toys Dreamworks:
I’ve tried teleporting the parts to the big part’s cframe but all of them teleported to the centre of the big part.
If anyone could help me solve this that would be great.
Use an offset by multiplying the CFrame by a scalar.
bigPart.CFrame * CFrame.new(1, 1.5, 1)
Wouldn’t they all still teleport to the same place inside of the big part, but just off to the side a little? Or would I have to tell the script where the parts can be teleported to randomly?
They would, that was just how to prevent them from being teleported to the center of the part, if you wanted random scatter, you could use the following:
local bigPart = workspace:WaitForChild("BigPart")
local smallPart = workspace:WaitForChild("SmallPart")
local function rand()
local randNum = 1 + (math.random(1, 10)/100)
return randNum
end
smallPart.CFrame = bigPart.CFrame * CFrame.new(1, rand(), 1)
1 Like
Would that not change the big part’s cframe?
Check the edit, you’ll probably need to change some stuff around, it’s just an example.
I actually already tried the exact same thing while waiting… It doesn’t seem to work unfortunately.