Gui broken and all scripts broken whenever I change the way the gui appear

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    So I’ve made a gui for a radio and I want it only to appear whenever the player is on a specific team, so I created a local script in starter player scripts which clone the radio guilocated inside the script to the player gui but whenever I do that, half the systems and scripts in the gui are now broken and some remove event don’t fire anymore.

  2. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried everything I could think off by modifying the scripts

-- This is an example Lua code block

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
image

2 Likes

So whenever I press the panic button, in the console, the first things print but then when I got to the script which is supposed to received the signal of the remote even being fired, it doesn’t work
image


image

See, it doesn’t print “Whatttt”

2 Likes

But then once I put the script in playergui before launching the game instead of making it clone then it works

2 Likes

It looks like you are using .Parent to define a pathway to an item.

That works as long as the items don’t move.

Unfortunately, anything placed into StarterCharacterScripts and StarterPlayerScripts will move when the player joins.

The items in StarterPlayerScripts will be placed into the Player.

The items in StarterCharacterScripts will be placed into the Character.

So, using .Parent will not work. You need to change the pathway to be directed to the actual Player and Character instead.

1 Like

looks like you did your ServerScript wrong

script.Parent.Panic_Remote.OnClientEvent:Connect(function(Player)
  ...
end)

the RemoteEvent should be inside of ReplicatedStorage
and the script should be in ServerScriptService (not with the event)

-- LocalScript inside the button
local RS = game:GetService("ReplicatedStorage")
local PanicEvent = RS.Panic_Remote -- The remote should be in ReplicatedStorage

local Player = game.Players.LocalPlayer
Cooldown = false

script.Parent.MouseButton1Click:Connect(function()
  if Cooldown then return end -- Ignore the click if cooldown is active
  print("NOOO")
  PanicEvent:FireServer() -- You don't need to pass player when doing :FireServer()
  print("LOL")
  Cooldown = true
  task.wait(30)
  Cooldown = false
end)
-- ServerScript in ServerScriptService
local RS = game:GetService("ReplicatedStorage")
local PanicEvent = RS.Panic_Remote

-- Use OnServerEvent on the server
--[[
Client -> Server (OnServerEvent)
Server -> Client (OnClientEvent)
]]

-- Player will always be the first argument when doing OnServerEvent
-- Player = Player who did :FireServer()
PanicEvent.OnServerEvent:Connect(function(Player: Player) 
  print("WHATTT")
  RS:FireAllClients() -- Don't need to pass player when firing all players
end)
1 Like

But all the items in the script are located on a gui, the only thing that move is when I clone the GUI into the player gui, does that still change something?

I misunderstood your screen capture.

But the problem looks to be the same.

If you clone the RadioGui into PlayerGui then you will have:

  1. Player/Radio/LocalScript
  2. Player/PlayerGui/RadioGui

Then .Parent will not work because they are in two different places.

So you need to clone them both to the same place.

Or, you could just have the LocalScript inside the RadioGui. (Update the pathways if you do this.)

Local scripts are inside the gui so for that I think it should be good. But what do you mean by updating the pathways?

I’ve followed your instructions and now it works! But now I encounter another problem, when I got on test with 2 players, only the player 1 receives the panic notifications on his radio and not the player 2, no matter who pressed the panic button.

Not sure is you meant to FireAllClients.

You can just FireClient(plr)

When I fire all clients but put “player” in brackets it’s because I want to get the player username so that it can show up on the notification.

Looks like the Remotes are not the same for everyone, or the wrong player is being sent.

I put together a quick file that shows how to send a panic alert through a remote.

Maybe it will help.

Remotes.rbxl (57.8 KB)

Look in the Output window after pressing the Panic button.

I think I had the basic for the script but yours looks much simpler. I will scrap my current scripts and try to rearrange them clearer to see if it works after that, thank you.