Hello!
I am wanting to showcase some trails, and am wanting to attach them to moving parts.
I want the part to move to random positions within a given radius of say 10 studs.
How would I do this?
Hello!
I am wanting to showcase some trails, and am wanting to attach them to moving parts.
I want the part to move to random positions within a given radius of say 10 studs.
How would I do this?
You could just use
task.wait(math.random(1,10))
Then move the part making sure its in a radius that you can define using variables
local part = script.Parent
local startPos = part.Position
local radius = 10
while task.wait(math.random(1,5)) do
part.Position = startPos + Vector3.new(math.random(-radius/2,radius/2),math.random(-radius/2,radius/2),math.random(-radius/2,radius/2))
end
My code is just going to be a more visual interpretation of @ItzBloxyDev’s code. My changes are just going to be to tween
the part’s instead of instantly moving them because OP said they wanted to showcase the trails.
local TweenService = game:GetService("TweenService")
local part = script.Parent
local startPos = part.Position
local radius = 10
while true do
local waitTime = math.random(5)
TweenService:Create(part, TweenInfo.new(waitTime), {
Position = startPos + Vector3.new(math.random(-radius/2, radius/2), math.random(-radius/2, radius/2), math.random(-radius/2, radius/2))
}):Play()
task.wait(waitTime)
end