Expected'end'(to close'then' at line 9), got <eof>; did you forget to close 'then' at line 21

I’m currently writing a script that will allow a GUI to appear when the block is clicked, but I’m having some trouble. Basically, if they have the game pass the UI shows up, but if they don’t it doesn’t allow them to click causing the UI not to show up.

In the output it says
“expected’end’(to close’then’ at line 9), got ; did you forget to close ‘then’ at line 21”’
Here’s the script…

Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()
local Give = game:GetService("ReplicatedStorage").Events:WaitForChild("Give")
local marketplace = game:GetService("MarketplaceService")
local gamepassid = script:WaitForChild("Gamepass ID").Value

local GamepassID = 10574037
game.Players.PlayerAdded:Connect(function(player)
	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserID, GamepassID) then
Mouse.Button1Down:connect(function()
	if Mouse.Target == nil then return end
	if Mouse.Target.Parent.Name == "PremiumIsland" then
				game.Players.LocalPlayer.PlayerGui.Fireplace.Frame.Visible = true
		game.Players.LocalPlayer.PlayerGui.Fireplace.Frame:TweenPosition(UDim2.new(0.5,0,0.5,0), "Out", "Bounce", 1)
	end
end)
	
			
Mouse.Button1Down:connect(function()
	if Mouse.Target == nil then return end
	if Mouse.Target:FindFirstChild("ClickDetector") then
		Give:FireServer(Mouse.Target.Name)
	end
end)
2 Likes

You need to add another end at line 9. That’s what the output is trying to say.

1 Like

These lines were your problem, you forgot to add 2 extra ends. One with a parenthesis closing the function, and another for the if statement checking if the player owns the gamepass.

local GamepassID = 10574037
game.Players.PlayerAdded:Connect(function(player)
	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserID, GamepassID) then
		Mouse.Button1Down:connect(function()
			if Mouse.Target == nil then return end
			if Mouse.Target.Parent.Name == "PremiumIsland" then
				game.Players.LocalPlayer.PlayerGui.Fireplace.Frame.Visible = true
				game.Players.LocalPlayer.PlayerGui.Fireplace.Frame:TweenPosition(UDim2.new(0.5,0,0.5,0), "Out", "Bounce", 1)
			end
		end)
	end
end)
6 Likes

Thanks! You helped me fix a problem similar to this.

2 Likes