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

ServerScriptService.Blast Handle:54: Expected 'end' (to close 'function' at line 7), got <eof>?

It says this error everytime i try to run my script i tried changing the position of end and it didnt seem to help. Here's the script:

local rs = game.ReplicatedStorage local FireBlast = rs.FireBlast local blast = rs.blast

local tweenService = game:GetService("TweenService")

local function blastFired(player)

local char = player.Character or player.Character:Wait()
local rootPart = char.HumanoidRootPart

local clone = blast:Clone()
clone.Parent = game.Workspace
clone.Position = rootPart.CFrame.LookVector.unit*6 + rootPart.Position 

local function blast_start()

	local info = TweenInfo.new(1, Enum.EasingStyle.Elastic, Enum.EasingDirection.Out, 0, false, 0)

	local goals = {

		Size = Vector3.new(5.4,5.4,5.4);
		Transparency = 0;

	}

	local startupTween = tweenService:Create(clone, info, goals)
	startupTween:Play()

	local function shootBlast()

		local info = TweenInfo.new(0.5, Enum.EasingStyle.Quart, Enum.EasingDirection.In, 0, false, 0)

		local goals = {

			CFrame = CFrame.new(rootPart.Position + rootPart.CFrame.LookVector.unit*200)

		}

		local shootTween = tweenService:Create(clone, info, goals)
		shootTween:Play()


	end	

	clone.Anchored = true
	blast_start()
	task.wait(1)
	clone.Anchored = false
	shootBlast()

end

FireBlast.OnServerEvent:Connect(blastFire)

1 answer

The function shootBlast() or blast_start() does not have an end statement. If you put “end” where the end of shootBlast() or blast_start() should be it should solve the problem. Anytime this happens just make sure each function has an end statement. If shootBlast() has an end statement where it should be then it’s most likely the other function. I also would recommend moving your functions outside each other. So instead of having shootBlast inside blastFired() it would look like this.


function shootBlast(variables)
end
function blastFired() 
shootBlast(any Variables you need shootBlast to have)
end

Your code would be transformed to be more readable like this.


local rs = game.ReplicatedStorage local FireBlast = rs.FireBlast local blast = rs.blast

local tweenService = game:GetService("TweenService")

local char = player.Character or player.Character:Wait()
local rootPart = char.HumanoidRootPart



local function shootBlast(clone)
  local info = TweenInfo.new(0.5, Enum.EasingStyle.Quart, Enum.EasingDirection.In, 0, false, 0)
  local goals = {

            CFrame = CFrame.new(rootPart.Position + rootPart.CFrame.LookVector.unit*200)

        }
   local shootTween = tweenService:Create(clone, info, goals)
        shootTween:Play()

end

local function blast_start(clone)
    local info = TweenInfo.new(1, Enum.EasingStyle.Elastic, Enum.EasingDirection.Out, 0, false, 0)

    local goals = {

        Size = Vector3.new(5.4,5.4,5.4);
        Transparency = 0;

    }

    local startupTween = tweenService:Create(clone, info, goals)
    startupTween:Play() 
end

local function blastFired(player)
  local clone = blast:Clone()
  clone.Parent = game.Workspace
  clone.Position = rootPart.CFrame.LookVector.unit*6 + rootPart.Position 
  clone.Anchored = true
  blast_start(clone)
  task.wait(1)
  clone.Anchored = false
  shootBlast(clone)
end

It allows you to see each function separately so you don’t lose track of the ends. Also allows you to work on each section without getting confused.

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