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

everytime i respawn my text updating script breaks,can someone help me?

Asked by 3 years ago

So i have a script for my gun the only problem is when i die the ammo value doesn't change after i re spawn, however everything else still works. it is a server script

local tool = script.Parent

tool.Equipped:Connect(function()
    _G.GUI = true
    while _G.GUI == true do 
        local name = script.Parent.Parent.Name
        if game.Workspace[tostring(name)].Humanoid.Health <= 0 then
            _G.GUI = false
            break
        else
            local gungui = game.Players[tostring(name)].PlayerGui:WaitForChild("gungui")
            local ammo = gungui:WaitForChild("am")
            local maxammo = gungui:WaitForChild("maxam")
            local currentammo = gungui:WaitForChild("Currentammo")

            if gungui:FindFirstChild("Currentammo") then


                currentammo.Text = ammo.Value .."/".. maxammo.Value
                wait()
        end



        end


    end
end)

tool.Unequipped:Connect(function()
    _G.GUI = false
end)

thankyou for reading, any help would be appreciated :)

0
1 - just make the _G.GUI a local outside every scope (aka just under the tool variable). I don't see the point in adding it there-...And also make sure you do a CharacterAdded event so this will re-run everytime you respawn. I'm at school rn so I can't look further into this as of now, but try making it in a different way. Like checking for any values changing via :GetPropertyChangedSignal() Antelear 185 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

fixed it was to do with my other script for updating theint value

Ad

Answer this question