Dialogue not working properly


So I am trying to make it where talking with an NPC will give you a “Stone”. The stone is given to the user properly and it works like intended. The only issue is the response dialog that the NPC gives. The response dialog is “…” when it gives the user a stone. It is suppose to say “Here is your stone.” It says “Here is your stone” when you talk to the NPC again after receiving your stone. I have become aware that the issue is because of InvokeServer() being slow. With that being said, how would I get around this? Is there a way for me to speed up invokeServer?

1 Like

What happens if you set up the test with the player already having the stone. Does it reply with “Test”?

I’m not too familiar with dialog, but in lines 41 and 44 is that what is telling the NPC to reply with the dialog, or does it just set what the dialog is going to be when the code tells it to reply?

When I set up the test with the player already having the stone, the NPC replies with “Here is your stone.” Line 41 and 44 is supposed to set what the dialogue is going to be when the code tells it to reply.

So when is the code telling it to reply with that ResponseDialog?
Check to see if that line of code is getting the right information.

Another thing to do is print variables before if checks so you can see if it’s actually what you are expecting.

For example:

print(Choice = ", choice)  
if (choice == Ask.giveStone) then
--code

This tells you what choice is. If it’s not right then the code following this section will be run incorrectly.
Say it’s nil, then the response will be “Here is your stone.”

Just a suggestion when supplying your code. Please don’t use screenshots.
Copy/Paste code here from Studio with 3 backticks (```) before and after it. That formats it and allows us to copy it instead of rewriting it to help you out.
It’s also quicker for you.

Okay I will keep that in mind. So I did the print variable before it checks like you said and it is correctly saying that the “giveStone” dialogue has been chosen. giveStone is the name of dialogue choice that gives the user a stone. So I am still puzzled. I still think it is invokeserver causing this issue.

Nevermind I fixed the issue. It turns out the invokeserver was causing the issue. So I decided to do this.

local MinerHead = Miner.Head
local Ask = MinerHead.Ask
local minerDialogue = remoteEvents.minerDialogue
local checkStone = checkInventory:InvokeServer("Stone") -- checks inventory initially.
--MINER DIALOGUE
Ask.DialogChoiceSelected:Connect(function(plr, choice)
	print(choice)
	if (choice == Ask.giveStone) then
		--local checkStone = true
		--Ask.giveStone.ResponseDialog = "Test."
		print(checkStone)
		--Ask.
		if(checkStone == true) then
			print("No stone given.")
			--minerDialogue:InvokeServer("You already have a stone.")
			Ask.giveStone.ResponseDialog = "Test."
		else
			print("Stone is given.")
			Ask.giveStone.ResponseDialog = "Here is your stone."
			giveItem:FireServer("Stone")
			checkStone = checkInventory:InvokeServer("Stone") -- make sure inventory check is
			--updated.
		end
	end
end)
1 Like

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