So, i want to make a secret button, that activates fires, and was supposed to display a frame that says someone lit up the thing, that will appear for 5 seconds. After the 5 seconds, it will disappear. And the frame doesn't appear at all.
My code: (its in a normal script, not in a localscript)
01 | local ClickDetector = script.Parent.ClickDetector |
02 | local ogien 1 = script.Parent.Parent.ogienjeden.Fire |
03 | local ogien 2 = script.Parent.Parent.ogiendwa.Fire |
04 | local ogien 3 = script.Parent.Parent.ogientrzy.Fire |
05 | local ogien 4 = script.Parent.Parent.ogiencztery.Fire |
06 | local tekst = game.StarterGui.ScreenGui.Frame.TextLabel |
07 | local ramka = game.StarterGui.ScreenGui.Frame |
08 |
09 | ClickDetector.MouseClick:connect( function () |
10 | ogien 1. Enabled = true |
11 | ogien 2. Enabled = true |
12 | ogien 3. Enabled = true |
13 | ogien 4. Enabled = true |
14 | ramka.Visible = true |
15 | tekst.Text = "Ktos podpalil automat biletowy przy zajezdni Lodygowa. *klap klask*" |
16 | wait( 5 ) |
17 | ramka.Visible = false |
18 | tekst.Text = "" |
19 | end ) |
The problem is you're editing the frame in the StarterGui
, whenever a player joins a game, all the ScreenGuis
in startergui gets cloned to something called "PlayerGui"
which is under the player object, so editing the startergui won't show anything on the player, because the player has another ScreenGui.
So what you can do, is:
01 | local ClickDetector = script.Parent.ClickDetector |
02 | local ogien 1 = script.Parent.Parent.ogienjeden.Fire |
03 | local ogien 2 = script.Parent.Parent.ogiendwa.Fire |
04 | local ogien 3 = script.Parent.Parent.ogientrzy.Fire |
05 | local ogien 4 = script.Parent.Parent.ogiencztery.Fire |
06 |
07 | ClickDetector.MouseClick:connect( function (plr) -- player that clicked |
08 | ogien 1. Enabled = true |
09 | ogien 2. Enabled = true |
10 | ogien 3. Enabled = true |
11 | ogien 4. Enabled = true |
12 | local ramka = plr.PlayerGui.ScreenGui.Frame -- new |
13 | local tekst = ramka.TextLabel -- new |
14 |
15 | ramka.Visible = true |
16 | tekst.Text = "Ktos podpalil automat biletowy przy zajezdni Lodygowa. *klap klask*" |
17 | wait( 5 ) |
18 | ramka.Visible = false |
19 | tekst.Text = "" |
20 | end ) |
Now it should work, even though I recommend only editing UIs through localscripts that are under the ScreenGuis, and you can communicate through RemoteEvents
from server to client, however that's more advanced but if you want to read about it you can check here
Hope I helped, if you have any questions please let me know!