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

Expected 'end' to close 'function' at line 2), got <eof> meaning?

So I've been trying to make some sort of mission take place when you click on a dialogbox, the code below is just a test mission i'm trying, but I got the error in the title and I'm not sure how to fix it I'm only new at scripting so

local Miku = game.Workspace.HatsuneMiku.Hair
Miku.DialogChoiceSelected:connect(function(player, choice)
	if (choice == Miku.Dialog) then
		game.Players.PlayerAdded:Connect(function(plr)
			script.Parent.Touched:connect(function(hit)
				if hit. Parent:FindFirstChild("Humanoid") then
					
					plr.PlayerGui.missionpassed.Frame.Visible = true
					game.Workspace.Sound:Play()
					wait(5.8)
					plr.PlayerGui.missionpassed.Frame.Visible = false
				end
			end)
		end)
	end

2 answers

What this means is you didn't close off your function you started at line 2. To fix this, simply add a ) to the final end. Don't forgot to accept meh answer.

8 comments

0

Thanks, will try rn

0

I got "Expected identifier, got ")"

0

Yeah, add the ) at the final, then remove the first )

0

Hmmm, doesn't seem to work

0

Hm, do you have discord?

0

This may come as a surprise but I actually do not

0

Is there any way you could invite me to a Team Create so i can see whats happening? Rblx Username: SBlankthorn

0

I've figured out the problem, but thanks for your help

###The problem is what SBlankthorn said. However, there's another problem. If the choice selected is Miku.Dialog, you're waiting for another player to be added to do code on the new player. This is why you shouldn't nest lots of events inside others. You're not modifying the current player.

local Miku = game.Workspace.HatsuneMiku.Hair
local selected = false

Miku.DialogChoiceSelected:Connect(function(player, choice) -- :Connect not :connect
    if choice == Miku.Dialog then -- brackets redundant 
        selected = true
    end
end)

script.Parent.Touched:Connect(function(part)
    if part.Parent:FindFirstChild("Humanoid") and selected then -- if you want them to have selected the dialog, we check if selected 
        script.Parent.Sound:Play()
        wait(5.8)
        script.Parent.Sound:Stop()
    end
end)

###You also can't modify the contents in PlayerGui from the server unless the server placed it there. But in general, the server shouldn't be modifying PlayerGui or its contents at all. Place the sound somewhere else like under the part.

6 comments

0

Do what he said ^ Hes better than me xD

0

Well that worked, thank you!

0

Okay I may sound like an idiot but how does one accept an answer

0

Under the desired answer

0

I actually don't see it so if it's alright I'll just leave it like this

0

ok

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