So i’ve made a script for a bat walk, but it’s creating an error here.
local Humanoid = game.Players.LocalPlayer.Character.Humanoid
“Humanoid is not a valid member of Model”
local walking = false
local plr = game.Players.LocalPlayer
local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local Humanoid = game.Players.LocalPlayer.Character.Humanoid
local tool = script.Parent -- Make sure the local script is inside of the tool.
local equipped = false
local Animation = script:WaitForChild("Run") -- Place animation inside of script.
local BatIdle = script:WaitForChild("BatIdle")
local Animation2 = script:WaitForChild("Run2") -- Place animation inside of script.
local Animation3 = script:WaitForChild("Run3") -- Place animation inside of script.
local Animation4 = script:WaitForChild("Run4") -- Place animation inside of script.
local runtrack = Humanoid:LoadAnimation(Animation)
local runtrack2 = Humanoid:LoadAnimation(BatIdle)
local runtrack3 = Humanoid:LoadAnimation(Animation2)
local runtrack4 = Humanoid:LoadAnimation(Animation3)
local runtrack5 = Humanoid:LoadAnimation(Animation4)
tool.Equipped:Connect(function()
equipped = true
runtrack2:Play()
end)
tool.Unequipped:Connect(function()
equipped = false
runtrack2:Stop()
print(equipped)
end)
game:GetService("UserInputService").InputBegan:Connect(function(keyPressed, gameProcessed)
if gameProcessed then return end
if not equipped then return end
if keyPressed.KeyCode == Enum.KeyCode.W then
game.ReplicatedStorage.ConnectM6D:FireServer()
runtrack:Play()
repeat
wait()
until not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.W)
runtrack:Stop()
else game:GetService("UserInputService").InputBegan:Connect(function(keyPressed, gameProcessed)
if gameProcessed then return end
if not equipped then return end
if keyPressed.KeyCode == Enum.KeyCode.A then
game.ReplicatedStorage.ConnectM6D:FireServer()
runtrack3:Play()
repeat
wait()
until not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.A)
runtrack3:Stop()
else game:GetService("UserInputService").InputBegan:Connect(function(keyPressed, gameProcessed)
if gameProcessed then return end
if not equipped then return end
if keyPressed.KeyCode == Enum.KeyCode.S then
game.ReplicatedStorage.ConnectM6D:FireServer()
runtrack4:Play()
repeat
wait()
until not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.S)
runtrack4:Stop()
else
game:GetService("UserInputService").InputBegan:Connect(function(keyPressed, gameProcessed)
if gameProcessed then return end
if not equipped then return end
if keyPressed.KeyCode == Enum.KeyCode.D then
game.ReplicatedStorage.ConnectM6D:FireServer()
runtrack5:Play()
repeat
wait()
until not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.D)
runtrack5:Stop()
end
end)
end
end)
end
end)
end
end)