You can write your topic however you want, but you need to answer these questions:
I’m making a script on pressing W while a weapon is equipped, a different walk animation is played.
The issue is, it’s not working. I’m also getting errors. This local script is inside the tool in StarterPack, by the way.
LOCAL SCRIPT:
local plr = game.Players.LocalPlayer
local Humanoid = plr.Character.Humanoid
local run = Instance.new("Animation")
run.AnimationId = "rbxassetid://5518064511"
local runtrack = Humanoid:LoadAnimation(run)
local bat = workspace.BaseballBat
script.Parent.Equipped:Connect(function()
game.ReplicatedStorage.ConnectM6D:FireServer(bat)
game.Players.LocalPlayer.Character:WaitForChild("ToolGrip")
game.Players.LocalPlayer.Character.Torso.ToolGrip.Part0 = game.Players.LocalPlayer.Character.Torso
game.Players.LocalPlayer.Character.ToolGrip.Part1 = bat
if game.StarterPack.Bat.Equipped == true then
game:GetService("UserInputService").InputBegan:Connect(function(Input, gameProcessed)
if not gameProcessed then
if Input.KeyCode == Enum.KeyCode.W then
runtrack:Play()
end
end
end)
if game.StarterPack.Bat.Equipped == true then
game:GetService("UserInputService").InputEnded:Connect(function(Input, gameProcessed)
if not gameProcessed then
if Input.KeyCode == Enum.KeyCode.W then
runtrack:Stop()
end
end
end)
game.StarterPack.Bat.Unequipped:Connect(function()
runtrack:Stop()
game.ReplicatedStorage.DisconnectM6D:FireServer()
end)
end
end
end)
I tried that, The bat is not appearing aswell. The remoteevents are listed in my serverscripts above.
LOCALSCRIPT:
local Player = game.Players.LocalPlayer
local run = Instance.new("Animation")
run.AnimationId = "rbxassetid://5518064511"
local bat = workspace.BaseballBat
Player.CharacterLoaded:Connect(function(char)
local Humanoid = char:WaitForChild("Humanoid")
local runtrack = Humanoid:LoadAnimation(run)
script.Parent.Equipped:Connect(function()
game.ReplicatedStorage.ConnectM6D:FireServer(bat)
game.Players.LocalPlayer.Character:WaitForChild("ToolGrip")
game.Players.LocalPlayer.Character.Torso.ToolGrip.Part0 = char.Torso
game.Players.LocalPlayer.Character.ToolGrip.Part1 = bat
if game.StarterPack.Bat.Equipped == true then
game:GetService("UserInputService").InputBegan:Connect(function(Input, gameProcessed)
if not gameProcessed then
if Input.KeyCode == Enum.KeyCode.W then
runtrack:Play()
print("walking")
end
end
end)
if game.StarterPack.Bat.Equipped == true then
game:GetService("UserInputService").InputEnded:Connect(function(Input, gameProcessed)
if not gameProcessed then
if Input.KeyCode == Enum.KeyCode.W then
runtrack:Stop()
end
end
end)
game.StarterPack.Bat.Unequipped:Connect(function()
runtrack:Stop()
game.ReplicatedStorage.DisconnectM6D:FireServer()
end)
end
end
end)
end)
Ohh, First off tools are not stored in the starterpack, they go into the players backpack from starterpack,
and put the localscript inside the tool, so that way you can just do script.Parent.Equipped:Connect(function())
Okay. I edited it, however same error. CharacterLoaded is not a valid member of player
local Player = game.Players.LocalPlayer
local run = Instance.new("Animation")
run.AnimationId = "rbxassetid://5518064511"
local bat = workspace.BaseballBat
Player.CharacterLoaded:Connect(function(char)
local Humanoid = char:WaitForChild("Humanoid")
local runtrack = Humanoid:LoadAnimation(run)
script.Parent.Equipped:Connect(function()
game.ReplicatedStorage.ConnectM6D:FireServer(bat)
game.Players.LocalPlayer.Character:WaitForChild("ToolGrip")
game.Players.LocalPlayer.Character.Torso.ToolGrip.Part0 = char.Torso
game.Players.LocalPlayer.Character.ToolGrip.Part1 = bat
if script.Parent.Equipped == true then
game:GetService("UserInputService").InputBegan:Connect(function(Input, gameProcessed)
if not gameProcessed then
if Input.KeyCode == Enum.KeyCode.W then
runtrack:Play()
print("walking")
end
end
end)
if script.Parent.Equipped == true then
game:GetService("UserInputService").InputEnded:Connect(function(Input, gameProcessed)
if not gameProcessed then
if Input.KeyCode == Enum.KeyCode.W then
runtrack:Stop()
end
end
end)
script.Parent.Unequipped:Connect(function()
runtrack:Stop()
game.ReplicatedStorage.DisconnectM6D:FireServer()
end)
end
end
end)
end)
No, its not CharacterLoaded, its CharacterAdded.
Change this
Player.CharacterLoaded:Connect(function(char)
local Humanoid = char:WaitForChild("Humanoid")
local runtrack = Humanoid:LoadAnimation(run)
script.Parent.Equipped:Connect(function()
game.ReplicatedStorage.ConnectM6D:FireServer(bat)
game.Players.LocalPlayer.Character:WaitForChild("ToolGrip")
game.Players.LocalPlayer.Character.Torso.ToolGrip.Part0 = char.Torso
game.Players.LocalPlayer.Character.ToolGrip.Part1 = bat
if script.Parent.Equipped == true then
game:GetService("UserInputService").InputBegan:Connect(function(Input, gameProcessed)
if not gameProcessed then
if Input.KeyCode == Enum.KeyCode.W then
runtrack:Play()
print("walking")
end
end
end)
to this.
Player.CharacterAdded:Connect(function(char)
local Humanoid = char:WaitForChild("Humanoid")
local runtrack = Humanoid:LoadAnimation(run)
script.Parent.Equipped:Connect(function()
game.ReplicatedStorage.ConnectM6D:FireServer(bat)
game.Players.LocalPlayer.Character:WaitForChild("ToolGrip")
game.Players.LocalPlayer.Character.Torso.ToolGrip.Part0 = char.Torso
game.Players.LocalPlayer.Character.ToolGrip.Part1 = bat
if script.Parent.Equipped == true then
game:GetService("UserInputService").InputBegan:Connect(function(Input, gameProcessed)
if not gameProcessed then
if Input.KeyCode == Enum.KeyCode.W then
runtrack:Play()
print("walking")
end
end
end)
Tried both, and it still does not load the animation,
LOCAL SCRIPT:
local bat = game.Workspace.BaseballBat
local Player = game.Players.LocalPlayer
local run = Instance.new("Animation")
run.AnimationId = "rbxassetid://5522808586"
Player.CharacterAdded:Connect(function(char)
local Humanoid = char:WaitForChild("Humanoid")
local runtrack = Humanoid:LoadAnimation(run)
script.Parent.Equipped:Connect(function()
game.ReplicatedStorage.ConnectM6D:FireServer(bat)
wait(1)
game.Players.LocalPlayer.Character:WaitForChild("ToolGrip")
game.Players.LocalPlayer.Character.Torso.ToolGrip.Part0 = char.Torso
game.Players.LocalPlayer.Character.ToolGrip.Part1 = bat
if script.Parent.Equipped == true then
game:GetService("UserInputService").InputBegan:Connect(function(Input, gameProcessed)
if not gameProcessed then
if Input.KeyCode == Enum.KeyCode.W then
runtrack:Play()
print("walking")
end
end
end)
if script.Parent.Equipped == true then
game:GetService("UserInputService").InputEnded:Connect(function(Input, gameProcessed)
if not gameProcessed then
if Input.KeyCode == Enum.KeyCode.W then
runtrack:Stop()
end
end
end)
script.Parent.Unequipped:Connect(function()
runtrack:Stop()
game.ReplicatedStorage.DisconnectM6D:FireServer()
end)
end
end
end)
end)
Also, the bat does not disappear after I unequip it, since that happens, i’ll show you the remote events aswell.
Ok so since your trying to do a walk animation with the roblox character. You have to change the default animation. This has to been done with in a server script, so this just got even more complex.
It now does work, problem is the Bat does not disappear on Unequip and the walk animations aren’t reverted, If you need a video, I can record it for you.
Ok, how about when you want the animation to work, fire a remote event, and when your done with it fire that same remoteevent again and just change the stuff there.and how about just making the bat invisible when its unequipped.