(I don’t know whether to label this as scripting or animations because I don’t know what causes this issue)
An animation for a katana is only working in solo testing in studio, or going in a team test and being the only player there. Once someone joins the team test, the animations cannot be seen by other players and stop working (for you) when you die. What I want is the animation for the sword to be seen for all players.
I believe it’s probably because it’s a LocalScript, but I’ve been stuck on this for a while and haven’t found a solution for this.
The animations are uploaded through my account and it’s a game me and 2 others are working on so that may also be the issue…?
wait()
local debounce = false
local tool = script.Parent
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char.Humanoid
local anim = hum:LoadAnimation(script.Parent.KatanaEquipAnim)
local attackanim = hum:LoadAnimation(script.Parent.UpdatedKatanaSwingAnim)
local mouse = player:GetMouse()
anim.Priority = Enum.AnimationPriority.Action
attackanim.Priority = Enum.AnimationPriority.Action
script.Parent.Equipped:Connect(function()
anim:Play()
end)
script.Parent.Unequipped:Connect(function()
anim:Stop()
end)
if debounce then return end
script.Parent.Activated:Connect(function()
if debounce == false then
debounce = true
attackanim:Play()
print("sword hit")
tool.Handle.Swing:Play()
wait(0.7)
debounce = false
end
end)
Why is your if debounce then return end supposed to do? It’s not inside any function.
Animations are played locally, then sent to the server so other players can see them.
If you game lags a lot they may never see the animations.
And what calls the script.parent.Activated function? What is being activated?
From the looks of it tool = script.parent (and yet you use script.parent instead of tool in a few other places in your script) so you have your animations loaded into the tool? From what I see you are loading the animation each time you run the functions: local anim = hum:LoadAnimation(script.Parent.KatanaEquipAnim)
If the script doesn’t have WaitForChild for some items it may error since things like the Player.LocalCharacter may not be loaded when the script starts.
Also I’ve researched the issue more and it’s because of the way I uploaded the animations, they’re meant to be uploaded to the group that’s linked to the game, not directly through my profile, so it doesn’t seem to be anything script related. But thanks for telling me about the errors in my script anyways.
Since the debounce is already taken care of in the last function it isn’t required at all between the functions. Debounces help inside functions to keep them from being spammed.
If you get rid of that line between the functions then it makes no difference.