``local part = script.Parent
``while true do
part.Position = Vector3.new(0.05,10,-10)
wait(0.3)
part.Position = Vector3.new(0.05,10.01,-10)
wait(0.3)
part.Position = Vector3.new(0.05,10.02,-10)
wait(0.3)
part.Position = Vector3.new(0.05,10.03,-10)
wait(0.3)
part.Position = Vector3.new(0.05,10.04,-10)
wait(0.3)
part.Position = Vector3.new(0.05,10.05,-10)
wait(0.3)
part.Position = Vector3.new(0.05,10.06,-10)
wait(0.3)
part.Position = Vector3.new(0.05,10.07,-10)
end ``
this can be a long script, do you know a way to shorten it?
You could try using a for loop, or you could try tweening the part.
Try for loops:
while true do
for i = 10,10.07,0.01 do
part.Position = Vector3.new(0.05,i,-10)
wait(0.3)
end
end
yes i am using a loop, i was gonna add more though
blokav
(blokav)
April 4, 2020, 7:36pm
5
[edit] didnāt notice the outer while-loop
local part = script.Parent
local start = 10
local stop = 10.07
local increment = 0.01
while (true) do
for i = start, stop, increment do
part.Position = Vector3.new(0.05, i, -10)
wait(0.3)
end
end
1 Like
while true do
part.Position = Vector3.new(0.05, part.Position.Y + .01, -10)
wait(0.3)
end
1 Like
This isnāt a for loop, this i a while loop that will run for a infinite time.
I didnāt know if he wanted it to keep going orā¦
n00kii
(nookii)
April 4, 2020, 7:51pm
9
just use a tween.
local TweenService = game:GetService("TweenService")
local repeatCount = 5
local tweenInfo = TweenInfo.new(1.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, repeatCount)
local tweenGoal = {Position = Vector3.new(0.5, 10.1, -10)
local tween = TweenService:Create(part, tweenInfo, tweenGoal)
tween:Play()
1 Like
local TweenService = game:GetService(āTweenServiceā) local repeatCount = 5 local tweenInfo = TweenInfo.new(1.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, repeatCount) local tweenGoal = {Position = Vector3.new(0.5, 10.1, -10) local tween = TweenService:Create(part, tweenInfo, tweenGoal) tween:Play()
[Workspace.Part.Script:6: Expected ā}ā (to close ā{ā at line 4), got ālocalā]
local TweenService = game:GetService(āTweenServiceā) local repeatCount = 5 local tweenInfo = TweenInfo.new(1.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, repeatCount) local tweenGoal = {Position = Vector3.new(0.5, 10.1, -10) local tween = TweenService:Create(part, tweenInfo, tweenGoal) tween:Play()
He forgot a }, Put this:
local TweenService = game:GetService("TweenService")
local repeatCount = 5
local tweenInfo = TweenInfo.new(1.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, repeatCount)
local tweenGoal = {Position = Vector3.new(0.5, 10.1, -10)}
local tween = TweenService:Create(part, tweenInfo, tweenGoal)
tween:Play()
1 Like
iGottic
(iGottic)
April 4, 2020, 8:55pm
13
Can be reduced to this, and still be readable:
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 5)
TweenService:Create(part, tweenInfo, {Position = Vector3.new(0.5, 10.1, -10)}):Play() -- This is what I normally do in my scripts.
You should give @TheTurtleMaster_2 the solution. It solves your problem.
minkmink
(minkmink)
April 4, 2020, 8:58pm
14
generally iād just tell you to use TweenService for that instead
1 Like