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

ScreenGui doesnt open but code runs with no errors?

Asked by
Kryptio 19
7 years ago
Edited 7 years ago

Not too sure what im doing wrong here, but I want this ScreenGui to appear when the player clicks on the NPC, well when the player does click on the NPC the script does work to a degree bec the player is anchored until they close out of the Gui (separate script). But the issue is i cant get the Gui to open only close... Ive tried it with and without the Frame and ive been at this for a few hours now and i just dont know what it is im doing wrong. please help

local clickdetector = game.Workspace.PalletTown1.NPCs.Kryptio.ClickDetector
clickdetector.MouseClick:Connect (function()

local ScreenGui = game.StarterGui.KryptioGui.Frame

    if ScreenGui.Visible == false then
        game.Players.LocalPlayer.Character.Torso.Anchored = true
        ScreenGui.Visible = true 
    end
ScreenGui.KryptioClickDetectorEvent:FireServer()    

end)
0
Also if my question is too broad just let me know. Kryptio 19 — 7y
0
Not to be rude or anything, but i suggest you don't make a pokemon game, as they are extremely complex, if you make mistakes like this. (Suppose its a pokemon game because of "PelletTown".) RubenKan 3615 — 7y
0
and i suggest dont tell someone not to do something like that, ive only just started scripting and i find that really disrespectful. I already have ideas on how to make the pokemon game work its just the stupid things i dont understand Kryptio 19 — 7y
0
If you think about remaking something like brick bronze, barely anyone would be able to do it, just want to point that out. RubenKan 3615 — 7y

1 answer

Log in to vote
2
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

You bind the click function to change something in the StarterGui. You have to use the Players PlayerGui instead.

StarterGui is the service that clones all instance inside of it, to the players PlayerGui when their character gets added. (On entering the game, or respawning)

How to use the Players PlayerGui

ClickDetectors give PlayerThatClicked as an argument, as such:

clickdetector.MouseClick:Connect (function(PlayerThatClicked)

Note, that PlayerThatClicked can be any name you want.

(Like clickdetector.MouseClick:Connect (function(Hello))

Now, you can do PlayerThatClicked.PlayerGui

Ad

Answer this question