Why is script not working

is this script correct?

wait(1)

local Dummy = script.Parent.Parent.Parent
local sound = script.EatSound
local RemoveAppleEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoveApple")
local ToolName = "Apple"
local Dialog = script.Parent

RemoveAppleEvent.OnServerEvent:Connect(function(plr)
	if plr.Backpack:FindFirstChild(ToolName) then
		-- Find on backpack
		local tool = plr.Backpack:FindFirstChild(ToolName)
		tool:Destroy()
		sound:Play()
		Dialog.ResponseDialog = "thx"
	elseif plr.Character:FindFirstChild(ToolName) then
		-- Find on character
		local tool = plr.Character:FindFirstChild(ToolName)
		tool:Destroy()
		sound:Play()
		Dialog.ResponseDialog = "thx"
	else
		Dialog.ResponseDialog = "bruh u dont have an apple"
	end
end)


like it doesnt change the response dialogue even if it gives or not

What is dialog if it is a screen gui with a text label? If so Dialog.ResponseDialog.Text = "thx"
if not what is dialog?!

uh i used the assistant for that dialog.responsedialog.text part so idk if it works

Screenshot 2024-09-04 at 5.26.52 PM
this dialog

So i assume Dialog variable is the dialog instance. If it is try looking at the documentation properties? for dialog. Dialog | Documentation - Roblox Creator Hub

yes it is its the variable of the dialog

In this case, Dialog could either be of type Dialog or a 2D UI Element, such as a TextLabel.


In the instance of it being a UIElement, ensure to change the Text property, by doing:

Dialog.ResponseDialog.Text = "[text]"

If it is a Dialog, I recommend to change the Dialog to a DialogChoice object.


Feel free to look at the documentation: https://create.roblox.com/docs/reference/engine/classes/DialogChoice

I never touched dialogues. But maybe this video could help you if you do not want to touch scripting? Seems like it is just a bunch of Instances under the Dialog. https://www.youtube.com/watch?v=Cxqw8OgM7MU

Don’t know about Dialogs, it’s also a DialogChoice instance, they’re a niche instance not used often

If you’re using a Dialog intead of a DialogChoice, you selected the wrong one, ResponseDialog is not a property of a Dialog instance

Also you can do both cases in one line, so you don’t have to modify both cases, only keep them separate if you’re gonna have differences between them

	local tool = plr.Backpack:FindFirstChild(ToolName) or plr.Character:FindFirstChild(ToolName)
	if tool then
		tool:Destroy()
		sound:Play()
		Dialog.ResponseDialog = "thx"
	else
		Dialog.ResponseDialog
	end

i meant it was a dialogchoice and that choice gives the apple if chosen, and i want the response of that to be thx if we give it and something else if we dont give it, the something else is the default response