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

This ScreenGui works, but yet doesn't?

Asked by 8 years ago

Hello and thank you for answering, looking, or anything else with my question.

The Setup

I have a ScreenGui called 'The Course' and it has a frame inside. Inside the frame is 3 text buttons, which each one has in it is a local script. Each local script has an onClicked() event that's suppose to happen. The first text button 'About' changes The Course's parent to ServerStorage, and brings out another Gui that is in a WIP. The second Text Button is 'Credit's Button' which, like the about, changes The Course's parent to Server Storage and get's a ScreenGui called 'ScreenGui1' and makes the parent StarterGui. And the last one is 'Play Button' Which by clicking it, the whole ScreenGui is deleted.

The Problem

It's the second button, 'Credit's Button', whenever I click it, the action does happen, but the first gui, 'The Course' doesn't disappear and 'ScreenGui1' doesn't appear. I checked the Transparency in each one, and it's at 0.1, which I have it on. Here's the local script in 'Credit's Button'

function onClicked()
    game.StarterGui["The Course"].Parent = game.ServerStorage
    game.ServerStorage.ScreenGui1.Parent = game.StarterGui
end
script.Parent.MouseButton1Click:connect(onClicked)

It's a simple code really, but it treats it as if we're dealing with Pathfinding. It doesn't make any sense why 'The Course' will still be present and seen, even in Serverstorage, same goes for 'ScreenGui1'.

Can you help me with this issue? Thank you.

1 answer

Log in to vote
1
Answered by
woodengop 1134 Moderation Voter
8 years ago

You can try accessing the PlayerGui by indexing the LocalPlayer, the LocalPlayer is a :1 property of game.Players, it access the local user in-game, so basically the LocalPlayer is you.


local Player=game.Players.LocalPlayer -- defined player through a variable

function onClicked()
    Player:WaitForChild("PlayerGui")["The Course"].Parent = game.ServerStorage
    game.ReplicatedStorage.ScreenGui1.Parent = Player:WaitForChild("PlayerGui")
end
script.Parent.MouseButton1Click:connect(onClicked)

Note: localplayer only works on a localscript, and localscripts can't access the ServerStorage. :fn1

Edited

Without replacing objects from there parents(guis), use the Visible Property.

function onClicked()
    Player:WaitForChild("PlayerGui")["The Course"].FrameNameHere.Visible=false
    game.ReplicatedStorage.ScreenGui1.FrameNameHere.Visible=true
end
script.Parent.MouseButton1Click:connect(onClicked) 
Ad

Answer this question