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

How can I make a GUI pop up on screen when an NPC is cloned into the game?

Asked by 5 years ago

I have an NPC in ReplicatedStorage and a script which clones it into workspace. I'm trying to create a GUI which pops up on screen for players when the NPC is cloned into workspace. Preferably I'd like to set it up so the GUI can begin to make a list as more NPCs are cloned into workspace. I just don't know how to approach the idea and or what to use when doing so.

To clarify:

https://gyazo.com/b58fe24c7f376d7488c811169357de18

Something like this where a notification can pop up in a scrollable list.

Any help will be useful. Thanks

1 answer

Log in to vote
0
Answered by
PlaasBoer 275 Moderation Voter
5 years ago
Edited 5 years ago

So you put that gui in game.StarterGui then put Enabled to false then put local script inside we will get back to that then in the script where npc gets clone you add a Remote Event. and :FireAllClients() function.

E.g

This is in the script where npc gets cloned.

local myRemoteEvent = game.ReplicatedStorage.TheNameOfTheEvent

--What this does is it send signal to each player where this event is being used
myRemoteEvent:FireAllClients()

This is in that local script of the gui you added in ScreenGui (The pop up gui)

local myRemoteEvent = game.ReplicatedStorage.TheNameOfTheEvent

--This will wait for the signal of FireAllClients() function.
myRemoteEvent.OnClientEvent:Connect(function()
    --here will be the code to enable the gui e.g gui.Enabled = true
end)

Read more

https://wiki.roblox.com/index.php?title=API:Class/RemoteEvent/FireAllClients https://wiki.roblox.com/index.php?title=API:Class/RemoteEvent/OnClientEvent https://wiki.roblox.com/index.php?title=API:Class/RemoteEvent

0
Thanks! Worked great. XxJackplaysroblox 2 — 5y
Ad

Answer this question