Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

ScreenGui doesnt open but code runs with no errors?

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)

4 comments

0

Also if my question is too broad just let me know.

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

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

0

If you think about remaking something like brick bronze, barely anyone would be able to do it, just want to point that out.

1 answer

✓ Accepted answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.