Here is the localscript in starterpack.
Player = script.Parent.Parent mouse = Player:GetMouse() function Open(key) key = key:lower() if key == "e" then game.StarterGui.Inventory.Main.Visible = true end end mouse.KeyDown:connect(Open)
If this is, in fact, a LocalScript
, the proper method to get the player is by using game.Players.LocalPlayer
.
Another thing is this: The Player's GUIs are NOT in game.StarterGui
. They're actually in the Player's PlayerGui
, which is inserted on load. Much like StarterPack
, StarterGui
just holds GUI
elements which are later on copied into each Player's PlayerGui
.
Here is how you could do what you want, though:
local plr = game.Players.LocalPlayer local mouse = plr:GetMouse() mouse.KeyDown:connect(function(key) if key:lower() == "e" then plr.PlayerGui.Inventory.Main.Visible = true end end)
If it's a local script, you can just use game.Players.LocalPlayer
instead of parenting up to it.
Anyways, your main problem is that you changed it in StarterGui. StarterGui is what players spawn with, NOT what they are currently seeing. Each time a player spawns, everything in StarterGui is cloned into PlayerGui. Therefore, if you want to affect what a player is currently seeing, you need to make your changes in PlayerGui.
Since you already have the player, you can just do Player.PlayerGui.Inventory.Main.Visible = true