GUI set to visible but not appearing

All the GUI is visible but the main frame transparency is 1 and its supposed to be like that.
How ever, when I turn the visibility on, the buttons don’t show.

Code:

local SG = game:GetService("StarterGui").ScreenGui
local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")

local Events = RS:WaitForChild("Events")
local doSpellEvent = Events:WaitForChild("DoSpellEvent")

local function fireSpellEvent(spellName, dmg, animId)
	doSpellEvent:FireServer(spellName, dmg, animId)
end

UIS.InputBegan:Connect(function(input, gpe)
	if gpe then
		return
	end
	
	if not gpe then
		if UIS.KeyboardEnabled and UIS.MouseEnabled then
			SG.SpellButtonList.Visible = false
			if input.KeyCode == Enum.KeyCode.E then
				fireSpellEvent("Water", 42, 9812237233)
			elseif input.KeyCode == Enum.KeyCode.X then
				fireSpellEvent("Fire", 60, 9818602099)
			elseif input.KeyCode == Enum.KeyCode.Q then
				fireSpellEvent("Wind", 101)
			end
		elseif UIS.TouchEnabled then
			for i, v in ipairs(SG.SpellButtonList:GetChildren()) do
				if v:IsA("TextButton") then
					v.Visible = true
				end
			end
			SG.SpellButtonList.Visible = true
		end
	else
		return
	end
end)
3 Likes

Are you purposely making it so it is only visible if a player is on mobile?

Use playergui rather than startergui…

game.Players.LocalPlayer.PlayerGui.ScreenGui

I forgot this was a way. Thank you for reminding me lol.

1 Like