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
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.
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)
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.