Hi, I was wondering why my local script isn't working, I have put it inside of StarterGui.
Here is the script:
01 | local ar = game.StarterGui.WeaponSelectorGUI.MainFrame.AssaultRifle |
02 | local cb = game.StarterGui.WeaponSelectorGUI.MainFrame.Crossbow |
03 | local gl = game.StarterGui.WeaponSelectorGUI.MainFrame.GrenadeLauncher |
04 | local pistol = game.StarterGui.WeaponSelectorGUI.MainFrame.Pistol |
05 | local rl = game.StarterGui.WeaponSelectorGUI.MainFrame.RocketLauncher |
06 | local smg = game.StarterGui.WeaponSelectorGUI.MainFrame.SMG |
07 | local shotgun = game.StarterGui.WeaponSelectorGUI.MainFrame.Shotgun |
08 | local sniper = game.StarterGui.WeaponSelectorGUI.MainFrame.Sniper |
09 | local turnFoward = game.StarterGui.WeaponSelectorGUI.MainFrame.TurnForward |
10 | local turnBack = game.StarterGui.WeaponSelectorGUI.MainFrame.TurnBack |
11 | game.ReplicatedStorage.RemoteEvents.RemoveCash.OnClientEvent:Connect( function () |
12 | ar.Text = "weapon is currently unavailable" |
13 | ar.Active = false |
14 | cb.Text = "weapon is currently unavailable" |
15 | cb.Active = false |
updated code:
01 | local PlayerGui = game.Players.LocalPlayer:WaitForChild( "PlayerGui" ) |
02 |
03 | local ar = PlayerGui.WeaponSelectorGUI.MainFrame.AssaultRifle |
04 | local cb = PlayerGui.WeaponSelectorGUI.MainFrame.Crossbow |
05 | local gl = PlayerGui.WeaponSelectorGUI.MainFrame.GrenadeLauncher |
06 | local pistol = PlayerGui.WeaponSelectorGUI.MainFrame.Pistol |
07 | local rl = PlayerGui.WeaponSelectorGUI.MainFrame.RocketLauncher |
08 | local smg = PlayerGui.WeaponSelectorGUI.MainFrame.SMG |
09 | local shotgun = PlayerGui.WeaponSelectorGUI.MainFrame.Shotgun |
10 | local sniper = PlayerGui.WeaponSelectorGUI.MainFrame.Sniper |
11 | local turnFoward = PlayerGui.WeaponSelectorGUI.MainFrame.TurnForward |
12 | local turnBack = PlayerGui.WeaponSelectorGUI.MainFrame.TurnBack |
13 |
14 | game.ReplicatedStorage.RemoteEvents.RemoveCash.OnClientEvent:Connect( function () |
15 | ar.Text = "weapon is currently unavailable" |
It should work when the server FireClient() is fired or else check your output one of the variables might be not found
You should use a LocalScript
(Well you already did it, so no need to change.) and put it in game.StarterPlayer.StarterPlayerScripts
. You must access the PlayerGui
instead of StarterGui
. Here's an example:
1 | local PlayerGui = game.Players.LocalPlayer:WaitForChild( "PlayerGui" ) |
2 | PlayerGui.ScreenGui.TextLabel.Text = "Text!" |
PRO TIP: Consider making a local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
and replace ALL of the game.StarterGui
text to PlayerGui
.
If it still did not work. Consider marking this as an answer. I will try to help. Because I don't know your game content so I was just helping you the piece of code that I think it's the main problem.