I am currently trying to make a script where upon the player clicking an image button, a ui will open up showing their inventory.
this is the code, it’s very simple.
for some reason though when i test it in game, it prints the text but doesn’t open the ui.
this is the output, there was no error. i changed the InventoryIn frame to active but it still didn’t work.
this is their placement in studio
this might be something very simple but i’m currently stuck on it, if anyone can help that would be greatly appreciated. ill update this post if i find a solution.
Plr = game.Players.LocalPlayer
open = script.Parent
work = Plr.PlayerGui:WaitForChild("CharacterSelect").InventoryIn
Open.Activated:Connect(function() -- This Event should work on All Devices
work.Visible = not work.Visible
if work.Visible == true then -- This just here to Debug, remove if you want
print("is open")
end
end)
CharacterSelect is the screenUi and it is enabled to true, if you mean BackgroundTransparency of InventoryIn, it is at 0.3 when visble and off. otherwise no
StarterGui cannot be accessed like that. I usually access StarterGui through the player using the game.Players.LocalPlayer.PlayerGui in localscripts. Here is how I would personally do this in a localscript inside of the button:
local Open = script.Parent
local player = game.Players.LocalPlayer
local work = plr:WaitForChild("PlayerGui").CharacterSelect.InventoryIn
Open.MouseButton1Click:Connect(function()
work.Visible = true
print("is open")
end)
If you ever wanted to do this same script inside of something like ServerScriptService, here is how you would go about it:
game.Players.PlayerAdded:Connect(function(player) -- gets the player that joins
local playergui = player:WaitForChild("PlayerGui") -- gets the player's gui
local Open = playergui.CharacterSelect.IvenIcon
local work = playergui.CharacterSelect.InventoryIn
Open.MouseButton1Click:Connect(function() -- when they click the button inside of their gui
work.Visible = true -- frame is visible
print("is open")
end)
end)
The reason why it was printing “is open” but not showing the frame is because the button function works but not the part where the GUI becomes visible.
If something doesn’t work please respond! I’d be happy to help