Need help on button not changing any properties of a stringvalue

Hello. I need some help on a gui button that I have, which when clicked, is supposed to destroy a stringvalue. This does not work for me, which is making me confused, because even when I reset roblox studio, nothing changed; the button was still not destroying the value. I need some help on this, because I have never seen anything like this in my past year of coding on Roblox. The gui button is “not clickable either” and when I click it, it doesn’t click properly like any other gui button. I’ve tried many solutions for this, but nothing seems to work. I also tried making a script that would change the value of the stringvalue, and after countless attempts, I couldn’t get anything.Here is my current script.

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Locationvalue:Destroy()
	end)

Try using Activated instead of MouseButton1Click.
if that doesn’t work try:

script.Parent.MouseButton1Click:Connect(function()
	game.Players.LocalPlayer.PlayerGui.PathToYourString.Locationvalue:Destroy()
end)

Another issue that I always personally encounter is a simple mistake.
Make sure your script has x.Value = 100 instead of x = 100

Try what @CircDev suggested, as well as make the button’s Active property to true. That will allow the button to be clicked on and allow it activate events for user input on the button.

You might also have some confusion with LocalScripts and server scripts. The server does not detect anything a local script did unless it is replicated, which means that the stringvalue will still be there for the server but not for the client.

I get that it’s very wrong to use server scripts for coding GUI but I just wanted to clear that up in-case you’re working on something that the server and the client works on.

I am using a localscript, and put @CircDev’s code into the localscript. I checked to see if the button was active, which it was already. I also tried putting Activated but it didn’t change anything.

Put a debugger print in the event and see if it prints anything at all

It prints, but when I’m in the gui, it still shows that it’s still there.

I think you are looking at the StarterGui instead of PlayerGui.

Yes, so it actually is not visible from playergui but is visible from startergui.

1 Like