Another solution would be to check
if Tool.Parent == Player.Character then
ur code
end
Replace the declarations with this:
local Player = game.Players.LocalPlayer
local Character = Player.Character or script.Parent.Parent.Parent
local Humanoid = Character:WaitForChild('Humanoid')
local UserInputService = game:GetService('UserInputService')
local Tool = script.Parent
local ToolEquipped = false
NOTE: I forgot waitforchild as the script runs at runtime but the objects donât load until a little after runtime.
Good news it got rid of that error, bad news no animation is playing at all and says this
check the declaration of Character as it is waiting from the player instance in game.Players
so I think something went wrong with the Character declaration.
can you send the script?
sure can!
local Player = game.Players.LocalPlayer
local Character = Player.Character or script.Parent.Parent.Parent
local Humanoid = Character:WaitForChild(âHumanoidâ)
local UserInputService = game:GetService(âUserInputServiceâ)
local Tool = script.Parent
local ToolEquipped = false
local AnimationID = ârbxassetid://7001909669â
local Debounce = true
local Key = âZâ
Tool.Equipped:Connect(function() ToolEquipped = true end)
Tool.Unequipped:Connect(function() ToolEquipped = false end)
UserInputService.InputBegan:Connect(function(Input, IsTyping)
if ToolEquipped then
if IsTyping then return end
local Animation = Instance.new(âAnimationâ)
Animation.AnimationId = AnimationID
local LoadAnimation = Humanoid:LoadAnimation(Animation)
LoadAnimation:Play()
wait(1)
Animation:Destroy()
Debounce = true
end
end)
My bad, change line 3 to this local Character = Player.Character or script.Parent.Parent.Parent.Character
Do you want me to change line 3 of the script which would be humanoid or line 3 of the text I previously sent which would be character? if character then this popped up
the line that says local character replace that line witht he new local character line
This is the new new script:
local Player = game.Players.LocalPlayer
local Character = Player.Character or script.Parent.Parent.Parent.Humanoid
local Humanoid = Character:WaitForChild('Humanoid')
local UserInputService = game:GetService('UserInputService')
local Tool = script.Parent
local ToolEquipped = false
local AnimationID = 'rbxassetid://7001909669'
local Debounce = true
local Key = 'Z'
Tool.Equipped:Connect(function() ToolEquipped = true end)
Tool.Unequipped:Connect(function() ToolEquipped = false end)
UserInputService.InputBegan:Connect(function(Input, IsTyping)
if ToolEquipped then
if IsTyping then return end
local Animation = Instance.new('Animation')
Animation.AnimationId = AnimationID
local LoadAnimation = Humanoid:LoadAnimation(Animation)
LoadAnimation:Play()
wait(1)
Animation:Destroy()
Debounce = true
end
end)
Sorry for this being such a hassle by the way so far| but this came up
I just edited the script a bit, it should work now.
script:
local Player = game.Players.LocalPlayer
local Character = Player.Character or script.Parent.Parent.Parent.Humanoid
local Humanoid = Character:WaitForChild('Humanoid')
local UserInputService = game:GetService('UserInputService')
local Tool = script.Parent
local ToolEquipped = false
local AnimationID = 'rbxassetid://7001909669'
local Debounce = true
local Key = 'Z'
Tool.Equipped:Connect(function() ToolEquipped = true end)
Tool.Unequipped:Connect(function() ToolEquipped = false end)
UserInputService.InputBegan:Connect(function(Input, IsTyping)
if ToolEquipped then
if IsTyping then return end
local Animation = Instance.new('Animation')
Animation.AnimationId = AnimationID
local LoadAnimation = Humanoid:LoadAnimation(Animation)
LoadAnimation:Play()
wait(1)
Animation:Destroy()
Debounce = true
end
end)
Please try to resume your answers and whatever other information you wanna give into a single reply. This contributes to the post by preventing âfloodingâ.
Ok sorry my fault will keep this in mind next time