Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 5 years ago

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

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

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.

0
Thanks, will try rn JunkoEnoshimas 5 — 5y
0
I got "Expected identifier, got ")" JunkoEnoshimas 5 — 5y
0
Yeah, add the ) at the final, then remove the first ) SBlankthorn 329 — 5y
0
Hmmm, doesn't seem to work JunkoEnoshimas 5 — 5y
View all comments (4 more)
0
Hm, do you have discord? SBlankthorn 329 — 5y
0
This may come as a surprise but I actually do not JunkoEnoshimas 5 — 5y
0
Is there any way you could invite me to a Team Create so i can see whats happening? Rblx Username: SBlankthorn SBlankthorn 329 — 5y
0
I've figured out the problem, but thanks for your help JunkoEnoshimas 5 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

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.

0
Do what he said ^ Hes better than me xD SBlankthorn 329 — 5y
0
Well that worked, thank you! JunkoEnoshimas 5 — 5y
0
Okay I may sound like an idiot but how does one accept an answer JunkoEnoshimas 5 — 5y
0
Under the desired answer User#19524 175 — 5y
View all comments (2 more)
0
I actually don't see it so if it's alright I'll just leave it like this JunkoEnoshimas 5 — 5y
0
ok User#19524 175 — 5y

Answer this question