A noob, TRYING to code sum dialogue system

so im tring to make a simple dialogue event for experimenting , but nothing is working… for some reason.

Capture

local scriptEvent = game:GetService("ReplicatedStorage"):WaitForChild("ScriptEvent")
local player = game:GetService("Players").LocalPlayer
local plrGUI = player.PlayerGui
local dialogueGUI = plrGUI:WaitForChild("Dialogue")

local UsernameTxt = dialogueGUI:WaitForChild("UsernameTxt")
local TextLine = dialogueGUI:WaitForChild("TextLine")
local Images = dialogueGUI:WaitForChild("Image")

scriptEvent.OnClientEvent:Connect(function(text, people, name)
	UsernameTxt.Value = name
	TextLine.Value = text
	Images.Value = people
end)
local player = game:GetService("Players").LocalPlayer
local plrGUI = player.PlayerGui
local dialogueGUI = plrGUI:WaitForChild("Dialogue")

local Usernamevalue = dialogueGUI:WaitForChild("UsernameTxt")
local textValue = dialogueGUI:WaitForChild("TextLine")
local imageValue = dialogueGUI:WaitForChild("Image")

local textDialogue = dialogueGUI.DialogueBox:WaitForChild("TextDialogue")
local username = dialogueGUI:WaitForChild("Username")
local charIMG = dialogueGUI:WaitForChild("CharacterImg")

Usernamevalue.Changed:Connect(function()
	username.Text = tostring(Usernamevalue.Value)
end)

textValue.Changed:Connect(function()
	textDialogue.Text = tostring(textValue.Value)
end)

imageValue.Changed:Connect(function()
	charIMG.Image = tostring(imageValue.Value)
	
end)
local scriptEvent = game:GetService("ReplicatedStorage"):WaitForChild("ScriptEvent")

function start()
	scriptEvent:FireAllClients(":(",{15398600822}, "mymy")
end

start()

pls help

p.s , my brain hurt

3 Likes

Looking at this hurts my brain too lol… There’s a lot of open sourced dialogue systems out there that are much more efficient…

For example:

You don’t have to take my advice though, but I feel like this a good option.

3 Likes

First of all, is there a reason you have a seperate localscript to receive OnClientEvent? And why are you using values? You could just directly change the text and the image from receiving the RemoteEvent’s signal. This would make using .Changed unnecessary and would be better for your script’s performance.

Also, can you please eleborate more about the issue? Are there any errors or is something in particular not working properly?

I believe to set the image id, you’ll have to put “rbxassetid://” in front of the id and put that into a string, so “rbxassetid://15398600822” in your case.

Could you please provide some more information so that I can understand your system more? Unless there is an oversight on my part or something I don’t see, I can’t pinpoint any issues in the code, only in the overall structure of the system.

If you are serious about the game you’re making, try to make it on you own.

While using these materials is a good option, I would more so recommend using them as learning material. You can use them as reference material for your own system and see what you can implement.

If you do decide to use open-source materials, at least do your best in understanding them and learning from them.

4 Likes

first of all, idk . My smoll brain try to figure out the logic and try to be extra.
edit : i think at that time, i try to challenge myself…

second , no there’s no error in the output!!! nothing is working, it doesn’t even do anything. i put print to detect if one of them is working. but nothing is printing.

third, ok next time ill remember to put rbxassetid.

forth, yea , i agree , i try to learn them, but is kinda confusing cause those script i see kinda complex, so i try to do it on my own, with my current knowledge.

2 Likes

so like the first part listens for an event called ‘ScriptEvent’ which is triggered when new dialogue needs to be displayed to the player. When this event is fired, it updates the username, text, and image elements in the dialogue GUI with the corresponding values received from the event.

The second part of the script listens for changes in the username, text, and image elements within the GUI. These elements might change dynamically during gameplay based on various events or interactions?? idk. When any of these values change, it updates the respective UI elements accordingly to reflect the changes.

The last part of the script is responsible for starting the dialogue system by firing the ‘ScriptEvent’ to all clients with some initial dialogue data.

1 Like

ok bro is your event even working, and also you need to use rbxassetid:// for imagelabel picture ids

1 Like

I just realized what the issue is. Your script which fires the remoteEvent starts before the client is loaded in, therfore it sends the signal to nobody since you, the player, are not loaded in yet. Your system should work fine besides this. Try this:

local scriptEvent = game:GetService("ReplicatedStorage"):WaitForChild("ScriptEvent")

function start()
	scriptEvent:FireAllClients(":(",{15398600822}, "mymy")
end
task.wait(10) -- wait for a bit, the client should have loaded after 10 seconds, might need to make this longer if you take a while to load, not sure how good your pc is.
start()

This isn’t a permanent solution, just for testing. When your system is done, you probably won’t be using it right at the start anyway but only when the player interacts with an NPC. I tried it out myself, and it worked after this.

Also, if you decide not to use values in the end, you can try using something like this:

-- Function that updates the dialogue box's text, character name, and their image
local function updateDialogue(dialogueText, image, characterName)
	textDialogue.Text = dialogueText
	userName.Text = characterName
	characterImage.Image = image
end

DialogueEvent.OnClientEvent:Connect(updateDialogue)
2 Likes
local plrGUI = player.PlayerGui
local dialogueGUI = plrGUI:WaitForChild("Dialogue")

local Usernamevalue = dialogueGUI:WaitForChild("UsernameTxt")
local textValue = dialogueGUI:WaitForChild("TextLine")
local imageValue = dialogueGUI:WaitForChild("Image")

local textDialogue = dialogueGUI.DialogueBox:WaitForChild("TextDialogue")
local username = dialogueGUI:WaitForChild("Username")
local charIMG = dialogueGUI:WaitForChild("CharacterImg")
local scriptEvent = game:GetService("ReplicatedStorage"):WaitForChild("ScriptEvent")


scriptEvent.OnClientEvent:Connect(function(text, people, name)
	username.Text = tostring(name)
	textDialogue.Text = tostring(text)
	charIMG.Image = tostring("rbxassetid://"..people)
	warn("yo u suck at coding, think smarter, not harder!!!1!")
end)

heres ur client script updated to be better, removed your unnecessary update thing, also added rbxasetid which makes images work, one above wont work because rbxassetid thing

2 Likes

That’s great, but there’s a small issue with the server script as well since the ID is put into a table. I’m guessing he wanted to make it so multiple people can be displayed at once?

If not, do this instead when you’re sending the signal to the clients:

scriptEvent:FireAllClients(":(", 15398600822, "mymy") -- removed the {} from the id
2 Likes

Damn, you truly are the better coder.

2 Likes

oh , now is working. Thx. i can’t believe i have to add just a single line of code to make everything working

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.