I’m trying to create a script that tweens a part to move. It is a server script in workspace. It works perfectly in studio’s “Run” testing mode and not the “Play” testing mode. What is strange is that when I change the tween to effect the size of the part instead of the position, it works in both “Run” and “Play” mode.
Here is the script that tweens the object to move that only works in “Run” mode:
local TweenService = game:GetService("TweenService")
local part = script.Parent
local Info = TweenInfo.new(
0.2, -
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
true,
0
)
local Goals = {
Position = Vector3.new(-5.586, 73.012, 502.17)
}
local movePart = TweenService:Create(part, Info, Goals)
while true do
movePart:Play()
print("PartMoved")
wait(math.random(2,15))
end
And here is the same script with the tween changed to effect size that works in both modes:
local TweenService = game:GetService("TweenService")
local part = script.Parent
local Info = TweenInfo.new(
0.2,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
true,
0
)
local Goals = {
Size = Vector3.new(100,100,100)
}
local makePartBiggerTween = TweenService:Create(part, Info, Goals)
while true do
makePartBiggerTween:Play()
print("PartGrew")
wait(math.random(2,15))
end
I think this little speck might be the root cause of your issue here (Within your first script), which causes an error to stir up hence why the Part is unable to move to its designated goal
Just remove that and it should work, and if it doesn’t do consider providing more context on what’s exactly happening with the “Part”
That speck actually isn’t even in my script, I must have added it accidentally when making this post.
For some more context, I have multiple parts with this script and the script is supposed to make them move down and return up at random intervals. It works fine in Run mode but in Play mode the parts stay still. A likely relevant piece of information I just discovered is that the parts stay still at a lower position than where they started. This must mean that the tween begins bringing the parts down and then stops for some reason. And when all I do is change the word “Position” in the script to “Size”, the tween works perfectly.
Please answer these questions so we can try to help you better:
Question 1) Are the parents in question anchored? If not, changing their position will have odd effects due to gravity.
Question 2) Do your parts change size or position outside of this script?
Please note: *A tween will not run (in my experience) if an object has already met the goals of the tween.
For example:
Part 1 has size (100, 100, 100). If you attempt to tween it to be at size (100, 100, 100) again, nothing will happen because it’s already that size.
Question 3) Is this a LocalScript or server Script?
*Note you should always try to do tweens on the client side, aka inside a LocalScript, whenever possible. Tweening from the server side takes data resources away from the server.
Question 4)
Instead of doing print(“PartMoved”), can you change that statement to something potentially more helpful for debugging? that could be
movePart.Completed:Connect(function()
print("After done, our position is", part.Position)
end)
while true do
print("Before played, our position is", part.Position)
movePart:Play()
wait(math.random(2,15))
end