Admin GUI string value not updating

Look further down for the whole script. But, it’s not updating a value in RepilcatedStorage. I believe I made a simple mistake, but I been working this for a good few hours going on my 5th hour working on this. 2.5 hours of trial and error. Still not working. I been using ROBLOX developer hub to help with a lot of pass errors, but I getting tired of reading things. Sorry for any grammar mistakes.
Part of the script that not working

local n = script.Parent.Parent
local p1 = script.Parent.Parent.p1.Value
local p2 = script.Parent.Parent.p2.Value
local announce = game.ReplicatedStorage:WaitForChild(“AnnouncementText”)
function onclick()
if n.p2.Value ~= “NOTHING” and n.p1.Value ~= “NOTHING” then
if n.p1.Value == “System” then
announce.Value = p2
elseif script.Parent.Parent.p1.Value ~= (“System” or “NOTHING”) then
announce.Value = p1…": "…p2

Whole script

local n = script.Parent.Parent
local p1 = script.Parent.Parent.p1.Value
local p2 = script.Parent.Parent.p2.Value
local announce = game.ReplicatedStorage:WaitForChild(“AnnouncementText”)
function onclick()
if n.p2.Value ~= “NOTHING” and n.p1.Value ~= “NOTHING” then
if n.p1.Value == “System” then
announce.Value = p2
elseif script.Parent.Parent.p1.Value ~= (“System” or “NOTHING”) then
announce.Value = p1…": "…p2
script.Parent.Parent.Done.Visible = false
script.Parent.Parent.Text.Visible = true
local d = script.Parent.Parent.System
d.Script.Disabled = false
d.Selectable = false
d.BackgroundTransparency = 0
d.TextTransparency = 0
d.TextStrokeTransparency = 0
d.Script.Disabled = false
local n = script.Parent.Parent.Message
n.Script.Disabled = false
n.Selectable = false
n.BackgroundTransparency = 0
n.TextTransparency = 0
n.TextStrokeTransparency = 0
script.Parent.Parent.p1.Value = “NOTHING”
script.Parent.Parent.Text.TextBox.LocalScript.Disabled = false
script.Parent.Parent.Visible = false
script.Parent.Parent.Sumbit.Text = “Select Message or System!”
end
end
end
script.Parent.MouseButton1Down:Connect(onclick)

Can you provide a the hierarchy of the script from the Explorer? That would help.

What do you mean? Can you give me an example.

fordf(1)

1 Like

Roger. Hold on. Getting the corping the image.

2 Likes

To cocatentate two values, use .., not ...

... is not valid syntax, unless the code got warped when you copy/pasted it.

Don’t worry, I’m still troubleshooting.

1 Like

I used . . not .

Doing some trial and error.

1 Like

Ah-ha!

I might have figured it out! You are using a TextBox, which does not even have a :MouseButton1Down() property. You need to use a TextButton instead.

1 Like

You press a button, which has MouseButton1Down() function.

I already have a button.

1 Like

F9 (Developer logs), are not helpful anymore not showing any errors.

1 Like

@Regen_erate I will try to fix it tomorrow. I have to go, due to school tomorrow. Thanks for the help!

2 Likes

List of issues I have found so far…

  • You are not going “far enough” in your Parent.Parent scheme. Add an extra.Parent and you should be good. point1

  • You are indeed using a TextBox and trying to obtain its non-existent :MouseButton1Down() property. You can see this here: point2

There are a few others, but here is some fixed code to start:

local n = script.Parent.Parent
local p1 = script.Parent.Parent.p1.Value
local p2 = script.Parent.Parent.p2.Value
local announce = game.ReplicatedStorage:WaitForChild("AnnouncementText")
function onclick()
    if n.p2.Value ~= "NOTHING" and n.p1.Value ~= "NOTHING" then
	    if n.p1.Value == "System" then
		    announce.Value = p2
	    elseif script.Parent.Parent.p1.Value ~= ("System" or "NOTHING") then
		    announce.Value = p1..": "..p2
		    script.Parent.Parent.Parent.Done.Visible = false
		    script.Parent.Parent.Parent.Text.Visible = true
		    local d = script.Parent.Parent.System
		    d.Script.Disabled = false
		    d.Selectable = false
		    d.BackgroundTransparency = 0
		    d.TextTransparency = 0
		    d.TextStrokeTransparency = 0
		    d.Script.Disabled = false
		    local n = script.Parent.Parent.Message
		    n.Script.Disabled = false
		    n.Selectable = false
		    n.BackgroundTransparency = 0
		    n.TextTransparency = 0
		    n.TextStrokeTransparency = 0
		    script.Parent.Parent.Parent.p1.Value = "NOTHING"
		    script.Parent.Parent.Parent.Text.TextBox.LocalScript.Disabled = false
		    script.Parent.Parent.Parent.Visible = false
		    script.Parent.Parent.Parent.Sumbit.Text = "Select Message or System!"
	    end
    end
end
script.Parent.MouseButton1Down:Connect(onclick)

Transpiled your script over to a code block:

local n = script.Parent.Parent
local p1 = script.Parent.Parent.p1.Value
local p2 = script.Parent.Parent.p2.Value
local announce = game.ReplicatedStorage:WaitForChild("AnnouncementText")
function onclick()
    if n.p2.Value ~= "NOTHING" and n.p1.Value ~= "NOTHING" then
        if n.p1.Value == "System" then
            announce.Value = p2
        elseif script.Parent.Parent.p1.Value ~= ("System" or "NOTHING") then
            announce.Value = p1..": "..p2

            script.Parent.Parent.Done.Visible = false
            script.Parent.Parent.Text.Visible = true

            local d = script.Parent.Parent.System
            d.Script.Disabled = false
            d.Selectable = false
            d.BackgroundTransparency = 0
            d.TextTransparency = 0
            d.TextStrokeTransparency = 0
            d.Script.Disabled = false

            local n = script.Parent.Parent.Message
            n.Script.Disabled = false
            n.Selectable = false
            n.BackgroundTransparency = 0
            n.TextTransparency = 0
            n.TextStrokeTransparency = 0

            script.Parent.Parent.p1.Value = "NOTHING"
            script.Parent.Parent.Text.TextBox.LocalScript.Disabled = false	
            script.Parent.Parent.Visible = false
            script.Parent.Parent.Sumbit.Text = "Select Message or System!"
        end
    end
end
script.Parent.MouseButton1Down:Connect(onclick)

I’m predicting that, if you are updating p1 and p2 regularly, you will have to update the announcement text using p1.Value and p2.Value.
Basically, change your references at the beginning to exclude the .Value part at the beginning:

local n = script.Parent.Parent.Parent
local p1 = n.p1
local p2 = n.p2
--...

And include the .Value part in your onclick function:

--...
announce.Value = p1.Value ..": ".. p2.Value

Other than this, I would follow @Regen_erate’s advice and add an extra .Parent to n like I did in my snippet as well as using a TextButton instead of a TextBox if you aren’t already.
Personally, I would also change the name of the second n just to avoid confusion, like calling it msg or something close to that, as well as using more descriptive yet concise names instead of d, n, etc, so you can keep track of your variables more easily, like system or part1.
You also set d.Script.Disabled twice in your function.
Also, this will always evaluate to true:

elseif script.Parent.Parent.p1.Value ~= ("System" or "NOTHING") then

This is because "System" or "NOTHING" evaluates to true first, so you would essentially be comparing if p1.Value ~= true.
You have to compare each string separately, because Lua just doesn’t like it and it should be a thing:

elseif p1.Value ~= "System" and p1.Value ~= "NOTHING" then

the devforum also automatically formats two dots as a single-character ellipsis (…) if it’s not in a code block

2 Likes

@goldenstein64 @Regen_erate. Thanks for fixing errors, but still not working.
I noticed I had two n variables, I fixed part.

1 Like
announce.Value = p1..": "..p2 

is having the problem. But, I am not sure why.

You should use game:GetService("Service") when accessing a top-level singleton instead of game.Service.

Edit: Meant to refer to OP’s code, not as a criticism of your code.

Edit: would’ve said “canonical” cough cough @ScriptingSupport if I understood what it meant lol

1 Like

In the context of programming, canonical programming refers to your codebase conforming to an certain standard. Using GetService is standard for fetching services as it does a lookup based on ClassName. In the case of direct indexation which is not canonical, you present certain issues. Whether they’re easy to avoid or not is irrelevant: the fact that it can happen is enough. Most issues revolve around the name.

  • Service names can be changed.

  • Some services are not properly named. They either retain the default name of Instance or break convention with a space (e.g. Run Service).

  • Conflicting instance names in the DataModel can potentially result in the wrong instance being indexed.

1 Like

@ScriptingSupport sorry, I am lost what does "canonical" mean? Did you mean Chronological?

I didn’t. I posted above what it means. Please be sure to read for any posts that may have answered your question before posting! :slightly_smiling_face: