Hi “TweenService: Create failed because Instance is null” is error in this script, but I don’t know why.
local tweenService = game:GetService("TweenService")
local tile = script:GetChildren()
local track = workspace.trat.Track
local ties = track.Ties
local tweenInfo = TweenInfo.new(0.2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
--local part = script.rusen
--local vozen = script.vozen
--------------------
for i = 1, #tile do
print(tile[i].Name)
while true do
for i = 1, #ties:GetChildren() do
print(ties[i].Name)
local tween = tweenService:Create( tile[i] , tweenInfo, {CFrame = ties[i].CFrame} )
tween:Play()
tween.Completed:Wait()
end
----------------------
end
end
The goal is for multiple parts to move along the route with a single script.
Tween gets stuck right at the first, but first comes to the first position where he should start.
Any ideas for a solution?
local tweenService = game:GetService("TweenService")
local tile = script:GetChildren()
local track = workspace.trat.Track
local ties = track.Ties
local tweenInfo = TweenInfo.new(0.2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
--local part = script.rusen
--local vozen = script.vozen
--------------------
for index,single_tile in pairs(tile) do
print(single_tile.Name)
while true do
for i = 1, #ties:GetChildren() do
print(single_tile.Name)
local tween = tweenService:Create( single_tile , tweenInfo, {CFrame = ties[i].CFrame} )
tween:Play()
tween.Completed:Wait()
end
----------------------
end
end
What was causing the error?
Your for i loop, because the i is a variable and its getting updated 2 times.
If you use pairs() loop in the first loop then it will fix the error
Your tile was getting this i variable
(Well I am not great at teaching, so sorry if you cant understand anything.)
local tweenService = game:GetService("TweenService")
local tile = script:GetChildren()
local track = workspace.trat.Track
local ties = track.Ties
local tweenInfo = TweenInfo.new(0.2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
--local part = script.rusen
--local vozen = script.vozen
--------------------
for index,single_tile in pairs(tile) do
print(single_tile.Name)
while true do
for index,tie in pairs(ties:GetChildren()) do
print(single_tile.Name)
local tween = tweenService:Create( single_tile , tweenInfo, {CFrame = tie.CFrame} )
tween:Play()
tween.Completed:Wait()
end
----------------------
end
end
now they have exchanged. only one still works, but this time the one that didn’t go before.
but I’m thinking about a pairs () loop, maybe I’ll come to something.
(I feel like the translator did something wrong with this, is it wrong?)