NOTE: I could not recreate the actual bug, but it goes like this:
- I equip the gun
- I get killed by the other player
- The gun won’t work after getting killed, but will work if I reset by myself*
(Maybe it’s because I’m using a Skinned Mesh character?)
I tried to disable the gun when the player dies, even deleting it. But this will only occur when the player is killed by another player. The error will say something about Health, specifically Health is not a valid member of Humanoid. The error will be present in the following script:
1.
runService.RenderStepped:Connect(function(dt)
local char = game.Players.LocalPlayer.Character
local hum = char:FindFirstChild("Humanoid")
DynamicCrosshair:Update(dt)
for i, v in pairs(player.Character:GetChildren()) do
if v:IsA("Tool") then
player.PlayerGui.HUD.Frame.Visible = true
OTS_CAMERA_SYSTEM:Enable()
DynamicCrosshair:Enable()
else
player.PlayerGui.HUD.Frame.Visible = false
if OTS_CAMERA_SYSTEM.IsEnabled then
OTS_CAMERA_SYSTEM:Disable()
end
DynamicCrosshair:Disable()
end
end
if hum.Health <= 0 then
hum:ChangeState(Enum.HumanoidStateType.Dead)
if OTS_CAMERA_SYSTEM.IsEnabled then
OTS_CAMERA_SYSTEM:Disable()
end
DynamicCrosshair:Disable()
end
end)
game.ReplicatedStorage.DamageGiven.OnClientEvent:Connect(function()
script.HitMarker:Play()
end)
But the thing is, after this error is shown, the gun will not work anymore, and I have to reset manually.
Can anybody help me? Thanks!