Ad
Log in to vote
1

textbutton isnt appearing in roblox studio game thing but is when i press stop?

Asked by 19 days ago

so im trying to make it so when you click the play button, the textbutton which is the shop button appears, i made it in localscript so it does .Visible = true it didnt work and i tried clicking on it while in game and set it to visible and it didnt appear too but when i click stop and im in like the game viewer it appears but not in the roblox studio game thing

0
i can record it and upload it to youtube if u guys dont understand Skymarek 4 — 19d
0
please provide a video recording. this lacks information. T3_MasterGamer 845 — 19d
0
thank you T3_MasterGamer 845 — 19d

1 answer

Log in to vote
0
Answered by 19 days ago

Ahh, I see. From your video, I can see that you're getting the Shop button by StarterGui. Always remember that you can't get a button from the StarterGui when the game starts. It's because when the game starts StarterGui will be moved to the client player and be renamed to "PlayerGui". Instead, you can get the "MenuGui" by playBtn.Parent.Parent:WaitForChild("Shop").

Why use WaitForChild? You must always use WaitForChild in a client script because most of the time the client loads faster than the server, and the server provides all Instances of the game, including GUIs. WaitForChild waits until a specific child has been found, and will return that child.

local camera = workspace.CurrentCamera
local playBtn = script.Parent
local gamelogo = script.Parent.Parent:WaitForChild("GameLogo")
local shop = playBtn.Parent.Parent:WaitForChild("Shop")

repeat
    task.wait(.1)
    camera.CameraType = Enum.CameraType.Scriptable
until camera.CameraType == Enum.CameraType.Scriptable

camera.CFrame = workspace:WaitForChild("MenuCamera").CFrame

local function onPlay()
    camera.CameraType = Enum.CameraType.Custom
    playBtn.Visible = false
    workspace:WaitForChild("MenuCamera"):Destroy()
    gamelogo:WaitForChild("A"):Destroy()
    gamelogo:WaitForChild("F"):Destroy()
    gamelogo:WaitForChild("K"):Destroy()
    shop.Visible = true
end

playBtn.Activated:Connect(onPlay)
Ad

Answer this question