Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

my tool text breaks upon dying, can someone please help?

Asked by 2 years ago

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 :)

0
Does the UI not change, or does the values itself not change? loowa_yawn 383 — 2y
0
the ui breaks, the values change however the UI just breaks gymsharklife1 54 — 2y
0
are you seeing "script exhaustion timeout" error? if so put a task.wait() or wait() on line 27 in your script since it only waits if gungui:FindFirstChild("Currentammo") but when you die it can't find the child so it does not wait and thus runs too fast. imKirda 4491 — 2y
0
hello, no i dont receive an error, however it still breaks gymsharklife1 54 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago
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.

Ad

Answer this question