Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I fix this CFrame which is delayed?

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

✓ Accepted answer
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.

1 comment

0

Thanks man, I appreciate the help!

This discussion is preserved as it was. New answers, comments, and votes are closed.