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

How come my Local Scripts dont work after disabling and enabling the UI?

So, I have a button to make the UI's Enabled factor to set to false (I.E making it invisible) and I have a button to make it enabled again to make it visible, but when it comes back visible, the scripts arent doing their job correctly. I did check while in the studio to see if the enabled factors of the scripts were set to enabled, and they were, but the scripts did not work after, and there are no errors, can someone help me figure it out?

Also: here are the scripts for enabling and disabling

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Enabled = false
	script.Parent.Parent.Parent.WhichGive.Enabled = false
	script.Parent.Parent.Parent.Background.getitback.Visible = true
end)

Disabling script above (not local) (this is in a textbutton in screen gui "GiveDie" )

Enabling script below: (is local) (this is in a textbutton in a screengui called background, currently invisble when join game)

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Parent.GiveDie.Enabled = true
end)

Local scripts inside textbuttons inside "GiveDie" UI

(all the same)

local player = game.Players.LocalPlayer
local playergui = player:FindFirstChild("PlayerGui")

script.Parent.MouseButton1Click:Connect(function()
    if not playergui.WhichGive.BACKI.Visible then
        playergui.WhichGive.BACKI.Visible = true
	else
		playergui.WhichGive.BACKI.Visible = false
	 script.Parent.Parent.Parent.WhichGive.BACKI.thename.Text = script.Parent.Text
	end
end)

1 answer

I just saw u have Disabling script that is not local inside the text button. Try making it Local script and lemme know if it worked!

Actually, now you cannot use Normal script in GUI or TextButtons and all.

Also, why are you indexing 'PlayerGui' in local script, you can simple use script.Parent....until you reach your destination.

And if you want to use PlayerGui, make sure to use :WaitForChild("PlayerGui") instead of :FindFirstChild("PlayerGui")

2 comments

0

Actually you can use Server Scripts, the problem in his code is because the way roblox replicates values, if its already that value on the server, it will not replicate

0

And its better using player.PlayerGui, it makes code more readable and is "global"

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