Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why won't this text button that destroys a gui work?

I have made this script to destroy a frame, but it can't seem to work. Can somebody please explain why?

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Frame = script.Parent.Parent

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

4 comments

0

What script is this? Are there any errors? Give us kore details rather than "It wont destroy it".

0

It worked fine to me, did you user a server script or a local script when you wrote this?

0

Odds are that you're using a server script. Just make it local.

0

I fixed it now, the thing is I used ScreenGui, instead of PlayerGui

1 answer

Three things could be wrong: 1. You're using a server or module script instead of a local. GUI's are ran on the client so they must use a local script. 2. You did not use the Parent property correctly. Perhaps you went one Parent too far if the local script is inside the GUI button. 3. You put the script in the wrong location so it doesn't run. Local scripts which are used in GUI's go inside the GUI itself. Server scripts go into ServerScriptService, for future reference. So at least one of these is your problem. We couldn't tell because you didn't explain how your explorer was set up and give all nessacary information.

This discussion is preserved as it was. New answers, comments, and votes are closed.