Hello, I'm trying to make a tweening gun but whenever I run the BoltAesthetic() function it just gets stuck on CasingAesthetic() and loops on it

------------------------------------------------------
local GunModel = script.Parent:WaitForChild("GunModel")
local Bolt = GunModel:waitForChild("Bolt")
local BoltBack = GunModel:WaitForChild("BoltBack")
local BoltFoward = GunModel:WaitForChild("BoltFoward")
local Casing = GunModel:WaitForChild("Casing")
local CasingIn = GunModel:WaitForChild("CasingIn")
local CasingOut = GunModel:WaitForChild("CasingOut")
local TweenService = game:GetService("TweenService")
------------------------------------------------------
local BoltSpeed = 0.2
local CaseSpeed = 0.1
local BoltInfo = TweenInfo.new(BoltSpeed)
local CaseInfo = TweenInfo.new(CaseSpeed)
----
local CASEANIM = {}
CASEANIM.Position = CasingOut.Position
CASEANIM.Transparency = 0
----
local BoltBackT = {}
BoltBackT.Position = BoltBack.Position
----
local BoltForwardT = {}
BoltForwardT.Position = BoltFoward.Position
------------------------------------------------------
local CaseOut = TweenService:Create(Casing,CaseInfo,CASEANIM)
------
local BoltShootBack = TweenService:Create(Bolt,BoltInfo,BoltBackT)
------
local BoltShootForward = TweenService:Create(Bolt,BoltInfo,BoltForwardT)
------------------------------------------------------
Casing.Position = CasingIn.Position
Casing.Transparency = 1
------------------------------------------------------ 
function CasingAesthetic()
	Casing.Position = CasingIn.Position
	Casing.Transparency = 1
	wait(1)
	CaseOut:Play()
	wait(CaseSpeed)
	Casing.Transparency = 1
	local FakeCase = Casing:Clone()
	FakeCase.Anchored = false
	FakeCase.Transparency = 0
	FakeCase.CanCollide = true
	FakeCase.Parent = workspace
end
------------------------------------------------------
function BoltAesthetic()
	Bolt.Position = BoltFoward.Position
	wait()
	BoltShootBack:Play()
	wait(BoltSpeed)
	CasingAesthetic()
	wait()
	BoltShootForward:Play()
	wait(BoltSpeed)
end
------------------------------------------------------
while true do wait(5)
	BoltAesthetic()
end

3 comments

0

try changing function CasingAesthetic to local function

0

Didn't work

0

Try adding print statements in between where you think the problem is, for example, print("got pass this part"), this way you'll see which print statements didn't run.