i have a script for my gun the only problem is when i die the ammo value doesn't change after i respawn, however everything else still works. it is a server script
local tool = script.Parent 02 03 tool.Equipped:Connect(function() 04 _G.GUI = true 05 while _G.GUI == true do 06 local name = script.Parent.Parent.Name 07 if game.Workspace[tostring(name)].Humanoid.Health <= 0 then 08 _G.GUI = false 09 break 10 else 11 local gungui = game.Players[tostring(name)].PlayerGui:WaitForChild("gungui") 12 local ammo = gungui:WaitForChild("am") 13 local maxammo = gungui:WaitForChild("maxam") 14 local currentammo = gungui:WaitForChild("Currentammo") 15 16 if gungui:FindFirstChild("Currentammo") then 17 18 19 currentammo.Text = ammo.Value .."/".. maxammo.Value 20 wait() 21 end 22 23 24 25 end 26 27 28 end 29 end) 30 31 tool.Unequipped:Connect(function() 32 _G.GUI = false 33 end)
any help would be appreciated :)
if game.Workspace[tostring(name)].Humanoid.Health <= 0 then _G.GUI = false break
You're setting the GUI to false if they die?
Even so, I don't see the point of
_G.Gui = true
Then checking if it is true...
Maybe the cause:
you have a break
in your script. I'm not sure but consider just getting rid of that, or putting a return in there. Not sure what the return would do but just test it.