Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I fix this CFrame which is delayed?

Asked by
Gokhaii 58
4 years ago

I have a script that shoots a beam and I'd like to have a sphere at the end of the beam to add a little detail. But the thing that is wrong is that the end sphere wont keep up with the position of the beam, even with a loop.

Here is my script:

for i, v in pairs(Folder:GetChildren()) do

if  v.Name ~= "InnerEndBall" and v.Name ~= "OuterEndBall" then
    local goal = {}
    goal.Size = v.Size + Vector3.new(0,0,350)
    goal.CFrame = v.CFrame * CFrame.new(0,0,-175)
    local info = TweenInfo.new(5.5)
    local tween = TweenService:Create(v,info,goal)
    tween:Play()    
     end
end 

spawn(function()        
    while wait() do
    EndBeamInner.CFrame = BeamW.CFrame
    EndBeamOutter.CFrame = BeamW.CFrame
    end
end)    

Long story short, the End Sphere's CFrame doesn't keep up with the Beam's CFrame even though it is in a loop.

1 answer

Log in to vote
1
Answered by
RAFA1608 543 Moderation Voter
4 years ago
Edited 4 years ago
for i, v in pairs(Folder:GetChildren()) do
coroutine.resume(coroutine.create(function()
if  v.Name ~= "InnerEndBall" and v.Name ~= "OuterEndBall" then
    local goal = {}
    goal.Size = v.Size + Vector3.new(0,0,350)
    goal.CFrame = v.CFrame * CFrame.new(0,0,-175)
    local info = TweenInfo.new(5.5)
    local tween = TweenService:Create(v,info,goal)
    tween:Play()    
     end
end 

spawn(function()        
    while wait() do
    EndBeamInner.CFrame = BeamW.CFrame
    EndBeamOutter.CFrame = BeamW.CFrame
    end
end)
end))
end

Perhaps this will work? Well, i use this to sync every part ever in a loop. It still isn't perfect, but it works.

0
Thanks man, I appreciate the help! Gokhaii 58 — 4y
Ad

Answer this question