Many scripts like this one fail to work after a player dies:
local enabled = true
local ding = game.Workspace.Sounds.Ding -- sound
local part = game.Workspace.Configuration.Koala1 -- name
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local UserInputService = game:GetService("UserInputService")
local gui = player:WaitForChild("PlayerGui")
local toolup = gui:WaitForChild("clickE")
local maxpickup = 20
local KoalaGUI = player.PlayerGui.HatUI.KoalaAdd
local count = game.ReplicatedStorage.HatValues.KoalaCount
local inventorycount = game.ReplicatedStorage.HatValues.KoalaInventoryCount
local pp = player.leaderstats.Credits
UserInputService.InputBegan:Connect(function(input,gameProccesedEvent)
local item = mouse.Target
local distance = player:DistanceFromCharacter(item.Position)
if mouse.Target == part and enabled == true and distance <= maxpickup and input.KeyCode == Enum.KeyCode.E then
ding:Play()
KoalaGUI.Enabled = true
count.Value = count.Value + 1
inventorycount.Value = inventorycount.Value + 1
KoalaGUI.TextLabel.Text = "+"..count.Value
part.Position = Vector3.new(100,100,100)
part.Transparency = 1
part.CanCollide = false
game.ReplicatedStorage.HatEvent.KoalaEvent:FireServer()
wait(1)
count.Value = 0
KoalaGUI.Enabled = false
enabled = true
part.Transparency = 0
part.CanCollide = true
end
end)
