So I am trying to update a PlayerGUI called GunGui but it's just not outputting anything in console. The recent filtering enabled disallows me from just using a to do this.
LOCALSCRIPT
local ReplicatedStorage = game:GetService("ReplicatedStorage").PlayerEvents
local updateWeaponGui = ReplicatedStorage:WaitForChild("UpdateWeaponGui")
while wait(.1) do
updateWeaponGui:FireClient()
end
SCRIPT
local ReplicatedStorage = game:GetService("ReplicatedStorage").PlayerEvents
local updateWeaponGui = ReplicatedStorage:WaitForChild("UpdateWeaponGui")
local function execute(player)
local gui = player:FindFirstChild("GunGui")
for _,v in pairs(player.Character:GetChildren()) do
if v.ClassName == "Tool" then
if (v:FindFirstChild("Ammo")) and (v:FindFirstChild("GunType")) then
if (v.Ammo.Value > 0) then
gui.Main.name.Text = "Gun Name: " .. v.GunName.Value
gui.Main.Ammo.Text = "Ammo: " .. v.Ammo.Value
gui.Main.Type.Text = "Gun Type: " .. v.GunType.Value
gui.Main.Reload.Visible = false
gui.Main.NoGun.Visible = false
elseif (v.Ammo.Value <= 0) then
gui.Main.name.Text = "Gun Name: " .. v.GunName.Value
gui.Main.Ammo.Text = "Ammo: " .. v.Ammo.Value
gui.Main.Type.Text = "Gun Type: " .. v.GunType.Value
gui.Main.Reload.Visible = true
gui.Main.NoGun.Visible = false
end
else
gui.Main.name.Text = "Gun Name: N/A"
gui.Main.Ammo.Text = "Ammo: N/A"
gui.Main.Type.Text = "Gun Type: N/A"
gui.Main.Reload.Visible = false
gui.Main.NoGun.Visible = true
end
else
gui.Main.name.Text = "Gun Name: N/A"
gui.Main.Ammo.Text = "Ammo: N/A"
gui.Main.Type.Text = "Gun Type: N/A"
gui.Main.Reload.Visible = false
gui.Main.NoGun.Visible = true
end
end
end
updateWeaponGui.OnClientEvent:Connect(execute)

2 comments
I don't think you can access a player's gui serverside
Wait() shouldn't be a condition.