Hi everyone!
I’ve come across an EXTREMELY frusturating issue where the localscript inside a tool fails to re-run on the player’s respawn. Here’s a snippet of my code:
local function equipped()
playerGui.Mouse.Enabled = true
userInputService.MouseIconEnabled = false
hud.Ammo.Visible = true
refreshAmmo()
tool.Sounds.Equip:Play()
idle:Play()
equip:Play()
replicatedStorage.Remotes.EquipWeapon:FireServer(gun, referenceRig, "Equip")
wait(0.5)
toolEquipped = true
end
The output prints something along the lines of “hud.Ammo is not a valid member of player.PlayerGui.HUD”
Yes, I got the names correct. Yes, I’ve made sure the label is inside the HUD screengui.
My theory on this is the failure to re-run the code, because just coincedentally, it throws the error when the tool is placed into the starter gear of a person, and then the person respawns.
Please help. : )
EDIT: Okay so apparently a simple fix to this was just to add a variable holding the textlabel in it.
Wow that took me hours to figure out