Weird part behaviour after using tweenservice

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I need that the target constantly moves between these random X,Y,Z positions

  2. What is the issue? Include screenshots / videos if possible!
    When i use my script the target goes to 0,0,0 position

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I didn’t find any so i’m making this post

 local collection = game:GetService("CollectionService")
local tweenservice = game:GetService("TweenService")


game.Workspace.Activate.ClickDetector.MouseClick:Connect(function()
	for i, model in pairs(collection:GetTagged("Target")) do
		local randomX = Random.new(-70, -60)
		local randomY = Random.new(1, 10)
		local randomZ = Random.new(-17, 17)

		local randomPosition = Vector3.new(randomX, randomY, randomZ)
	
		local tweeninfo = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
		local tween = tweenservice:Create(model:FindFirstChild("Part"), tweeninfo, {Position =  randomPosition})
		tween:Play()
	end
end)

Print the random position and post what is comes out too.

You’re using random.new this is actually a seed creation for random number generation. What you should use is

math.random(-10,10)

image

But i don’t know why

I’ve edited my original solution, my bad for being hasty.

That worked just well
Thanks!

(When i tried to print random.new number it printed “Random” but now it’s just the values as needed)

1 Like