Hi! I was working on this script right here, but I found a lot of errors in the output. The script is suppose to only happen when the player is running and is holding the boom box. I looked all over the internet before making this post to make sure I wasn’t making a simple mistake, but I couldn’t find a single thing relating to this issue. It should also have the boombox in hand when running the animation. I’m not really sure if that’s just added the second you run the animation or if you have to add it in using scripts. Here’s what the script looks like and heres my workspace:
local Anim = game.Players.Animation
if Enum.HumanoidStateType.Running and game.StarterPack.BoomBox.Equipped then
Anim:Play()
end
You’re not contacting the Client’s tool. Instead, you are contacting the tool for all the Clients in the game through StarterPack. (Which isn’t necessarily a bad thing, but if it’s something you want the animation to play separately, then yeah it could be a problem.)
The code is already being passed through after equipping the tool. Instead, why not just use an Equipped function?
For example, why not try:
local Tool = script.Parent
Tool.Equipped:Connect(function()
--code
end)
Seeing as the script is inside the tool, you might as well just do script.Parent
Also you’re not checking whether the player is walking correctly
It’s kind of messy though and a lot of unnecessary things, probably can be cleaned up
(the reason I’m using active = false/true is because I can’t use connect and ifs all in 1 statement, and it ends up automatically looping even when the tool becomes unequipped)
local player = game:GetService("Players").LocalPlayer
local active = false
script.Parent.Equipped:Connect(function()
active = true
player.Character.Humanoid.Running:Connect(function(speed)
if speed > 0 and active == true then
print("hi")
else
active = false
end
end)
end)
Hi! This does print hi when the dj is equipped and is walking. However, I don’t know how to load the animation I’ve looked up some tutorials on how to load the animations but it doesn’t work.