Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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
0
Thank you. BabyHades_2 40 — 4y
Ad
Log in to vote
0
Answered by
Syclya 224 Moderation Voter
4 years ago

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

Answer this question