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

I made a script for a store but for some reason the GUI won't enable, can anyone help me?

I think I should add something like function or something like that

local clickdetector = workspace.PassportDealer.ClickDetector
local GUI = game.StarterGui.PassportGUI
local tool = game.ServerStorage.Passport

clickdetector.MouseClick:Connect(function()
	GUI.Enabled = true
end)


GUI.Frame.X.MouseButton1Click:Connect(function()
	GUI.Enabled = false
end)

GUI.Frame.ImageButton.MouseButton1Click:Connect(function()
	tool.Parent = game.StarterPack
end)

2 answers

✓ Accepted answer

Here is your problem:

local GUI = game.StarterGui.PassportGUI

You have to use the PlayerGui rather then the StarterGui:

local GUI = game.Players.LocalPlayer.PlayerGui.PassportGUI

1 comment

0

Thank you.

First of all, you're editing StarterGui and not PlayerGui (StarterGui objects is being cloned inside a folder called PlayerGui that's inside the player)

Second, a localscript cannot access any serversided services, such as ServerScriptService and ServerStorage.

Third, you'd want to use :WaitForChild on the PassportDealer as it might not have been replicated to the client yet.

(I assume this is a localscript as you're doing UI-related things, such as editing a gui.)

Example:

local clickdetector = workspace.PassportDealer.ClickDetector
-- Will error if clickdetector hasn't replicated

local clickdetector = workspace:FindfirstChild("PassportDealer").ClickDetector
-- Won't error, but clickdetector will be nil if the clickdetector hasn't replicated

local clickdetector = workspace:WaitForChild("PassportDealer").ClickDetector
-- Will wait until the clickdetector has replicated before continuing

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