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)
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