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

GUI, giver doesn't work.. the script doesn't give the localplayer the gui?

Asked by
iDevity -2
7 years ago
Edited by M39a9am3R 7 years ago
frame1 = script.Parent.Parent.Parent.Frame1
player = game.Players.LocalPlayer
Job = script.Parent.Parent.Parent.Parent.Job.Frame
script.Parent.MouseButton1Click:connect(function()
    player:WaitForChild('PlayerGui')
 frame1:remove()
    wait(5)
    game.Playergui.Job.Frame.Visible=true
    Job:clone().Parent = player.PlayerGui


end)

0
Could you please Code Block that script ALANstar360 45 — 7y

3 answers

Log in to vote
0
Answered by 7 years ago

Luckily, there appears to be a simple solution to this. game.PlayerGui does not exist. What you would need to access is game.StarterGui.

If your problem persists, I would double check that you are navigating the object library correctly. Things can easily get confusing with all of the .Parent's and it is easy to get lost. It has happened to me plenty of times.

0
No. StarterGui is the guis that all players spawn with. Use PlayerGui under Player module. hiimgoodpack 2009 — 7y
Ad
Log in to vote
0
Answered by 7 years ago
frame1 = script.Parent.Parent.Parent.Frame1
player = game.Players.LocalPlayer
Job = script.Parent.Parent.Parent.Parent.Job.Frame
script.Parent.MouseButton1Click:Connect(function()
    player:WaitForChild('PlayerGui')
    frame1:Destroy()
    wait(5)
    Job.Frame.Visible=true -- if Job is a variable then you don't need anything before it.
    Job:Clone().Parent = player.PlayerGui
end)


also like spyclub65 said, PlayerGui is not a member of game, rather the player. just in case, this should be a localscript inside a GUI inside of StarterGui

if you ever want to reference a player's GUI, use either script.Parent or game.Players.LocalPlayer.PlayerGui

Log in to vote
0
Answered by
Ap_inity 112
7 years ago
Edited 7 years ago

I've rewritten your script, here it is.

local frame1 = script.Parent.Parent.Parent.Frame1
local player = game.Players.LocalPlayer
local job = script.Parent.Parent.Parent.Parent.Job.Frame

script.Parent.MouseButton1Click:connect(function()
    player:WaitForChild('PlayerGui')
    frame1:Destroy()
    wait(5)
    player.PlayerGui.Job.Frame.Visible=true
    job:Clone().Parent = player.PlayerGui
end)


0
Remember, this would not be FE friendly. hiimgoodpack 2009 — 7y

Answer this question