You see, I’m having trouble with the dialogue GUI for my story game.
The script in ServerScriptService:
local status = game.ReplicatedStorage:WaitForChild("Status")
local dialogueEv = game.ReplicatedStorage.RemoteEvents.GuiEvents.Dialogue
local toggleDialogue = game.ReplicatedStorage.RemoteEvents.ToggleEvents.ToggleDialogue
local Npc = game.Workspace.NPC.Mike
local NpcImg = "rbxassetid://2128423326"
local NpcName = Npc.Name
local NpcFace = Npc.Head.face
local playerName
local playerImg
local function randomPlayer()
local players = game.Players:GetPlayers()
local playerNumber = math.random(1, #players)
local chosen = players[playerNumber]
playerImg = game.Players:GetUserThumbnailAsync(chosen.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
playerName = chosen.Name
end
wait(3)
dialogueEv:FireAllClients("Testing, Testing. 1, 2, 3...")
The local script in the dialogue screen GUI:
local toggleDialogue = game.ReplicatedStorage.RemoteEvents.ToggleEvents.ToggleDialogue
toggleDialogue.OnClientEvent:Connect(function(toggle)
if toggle == true then
script.Parent.Frame.Visible = true
else
if toggle == false then
script.Parent.Frame.Visible = false
end
end
end)
The local script in a folder in StarterGui:
local player = game.Players.LocalPlayer
local dialogueEv = game.ReplicatedStorage.RemoteEvents.GuiEvents.Dialogue
local Frame = player.PlayerGui:WaitForChild("Dialogue").Frame
dialogueEv.OnClientEvent:Connect(function(PlayerImage, PlayerName, Dialogue)
Frame.Visible = true
Frame:WaitForChild("TextLabel").Text = PlayerName
Frame:WaitForChild("Player").Image = PlayerImage
for ticker = 1, #Dialogue, 1 do
Frame:WaitForChild("Ticker").Text = string.sub(Dialogue, 1, ticker)
wait(0.04)
end
end)
Your string “Testing, Testing. 1, 2, 3…” is being passed into PlayerImage and PlayerImage alone, resulting in the values of PlayerName and Dialogue being nil.
Well, this is all essentially dependent on how you want your dialogue system to run.
If you’re just trying to do a simple test, replace the server script with the following code:
local status = game.ReplicatedStorage:WaitForChild("Status")
local dialogueEv = game.ReplicatedStorage.RemoteEvents.GuiEvents.Dialogue
local toggleDialogue = game.ReplicatedStorage.RemoteEvents.ToggleEvents.ToggleDialogue
local Npc = game.Workspace.NPC.Mike
local NpcImg = "rbxassetid://2128423326"
local NpcName = Npc.Name
local NpcFace = Npc.Head.face
local playerName
local playerImg
local function randomPlayer()
local players = game.Players:GetPlayers()
local playerNumber = math.random(1, #players)
local chosen = players[playerNumber]
playerImg = game.Players:GetUserThumbnailAsync(chosen.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
playerName = chosen.Name
end
wait(3)
randomPlayer()
dialogueEv:FireAllClients(playerImg, playerName, "This is a test dialogue.")
The code behind this should be pretty self-explanatory, but if you would like me to explain anything in more detail, let me know.