local uis = game:GetService('UserInputService')
local remote = game.ReplicatedStorage.bomb.bombevent
local hum = game.Players.LocalPlayer.Character.Humanoid
uis.InputBegan:Connect(function(key)
if key == Enum.KeyCode.E then
remote:FireServer("throw")
local an = script.T
local ani = hum:LoadAnimation(an)
ani:Play()
end
end)
You need to wait for the character to load
Should be:
local uis = game:GetService('UserInputService')
local remote = game.ReplicatedStorage.bomb.bombevent
local Player = game.Players.LocalPlayer
local character = Player.Character or Player.CharacterAdded:Wait()
local hum = character:WaitForChild("Humanoid")
uis.InputBegan:Connect(function(key)
if key == Enum.KeyCode.E then
remote:FireServer("throw")
local an = script.T
local ani = hum:LoadAnimation(an)
ani:Play()
end
end)
Trying to get the Player’s Character before even creating the script 's functions may give errors, try getting the character when the Player presses, so the script see it exists.
uis.InputBegan:Connect(function(key)
local Character = Player.Character
local hum = Character.Humanoid
if key == Enum.KeyCode.E then
remote:FireServer("throw")
local an = script.T
local ani = hum:LoadAnimation(an)
ani:Play()
end
end)