Why isnt this script working

working on a dialogue script with option trees.

When I call the function it doesn’t change the text, but when I print the text it says its changed. Its not a local script.

cant tell if i’m being stupid or theres an actual issue here.

local folder = script.Parent

--how are you doing today?

-------------------------
local A10 = folder.A10
local A20 = folder.A20
local A30 = folder.A30 -- ENDBLOCK
-------------------------
local B10 = folder.B10
local B20 = folder.B20
local B30 = folder.B30 -- ENDBLOCK
-------------------------
local A1B1 = folder.A1B1  
local A1B2 = folder.A1B2 -- ENDBLOCK
local A2B1 = folder.A2B1 -- ENDBLOCK
-------------------------
local B1A1 = folder.B1A1
local B1A2 = folder.B1A2 -- ENDBLOCK
local B2A1 = folder.B2A1 -- ENDBLOCK
-------------------------

function giveendblock(part, val)
	local endblock = Instance.new("StringValue")
	endblock.Name = "ENDBLOCK"
	endblock.Value = val
	endblock.Parent = part
end

function option(part, phrase, op1, op2)
	local gui = part:FindFirstChild("SurfaceGui")
	local text = gui.TextLabel.Text
	local choice1 = part.choice1.Value
	local choice2 = part.choice2.Value
	text = phrase .. "Yes"
	choice1 = op1
	choice2 = op2
end


option(A10, "Thats great to hear", "thanks","I appreciate it")

Where is this script located? Is it a server script or a local script?

Its a server script, it’s located inside a folder that has all the parts for the dialogue tree

local choice1 = part.choice1.Value
local choice2 = part.choice2.Value

you might need to get rid of .Value because its just storing the value inside that variable
edit1: also get rid of the .Text

2 Likes

I would recommend using remote events to communicate with the clients, as server scripts cannot directly communicate with the client.

I don’t think you’re allowed to do this

local choice1 = part.choice1.Value
choice1 = op 

and expect it to change choice1.Value.
If value is an int, it returns an int, not a pointer. As far as I’m aware.

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