#Server side not working for some reason regarding use of UAS

1 messages · Page 1 of 1 (latest)

north knoll
#

idk it's probably something simple pls help. What's happening is that when I click "C" the player is supposed to equip/unequip their claws. However, the claws are equipped and are never unequipped, because the script doesn't make it all the way through. I can't figure out why this is...

local Claw_Action_RE = game:GetService("ReplicatedStorage"):WaitForChild("ClawAction")
local anim_folder = script:WaitForChild("Animations")
local attacks, transitions, status = anim_folder:WaitForChild("Attacks"), anim_folder:WaitForChild("Transitions"), anim_folder:WaitForChild("Status")
local status_anim: AnimationTrack = nil
local equipped = false

Claw_Action_RE.OnServerEvent:Connect(function(plr: Player, request: string)
    local char = plr.Character or plr.CharacterAdded:Wait()
    local animator: Animator = char:WaitForChild("Humanoid"):WaitForChild("Animator")
    print(request)
    
    if request == "Equip" and not equipped then
        if status_anim then status_anim:Stop(); status_anim:Destroy(); end
        
        
        local init_anim = animator:LoadAnimation(transitions:WaitForChild("EquipClaws"))
        init_anim.Looped = false
        init_anim:Play(0.02)
        
        init_anim.Ended:Wait()
        
        local equipped_anim = animator:LoadAnimation(status:WaitForChild("ClawsEquipped"))
        status_anim = equipped_anim
        equipped_anim.Looped = true
        equipped_anim:Play(0.02)
        
        plr.PlayerGui:WaitForChild("ClawsEquipped").Enabled = true
        plr.PlayerGui:WaitForChild("ClawsUnequipped").Enabled = false
        
    elseif request == "Unequip" and equipped then
        if status_anim then status_anim:Stop(); status_anim:Destroy(); end

        local init_anim = animator:LoadAnimation(transitions:WaitForChild("UnequipClaws"))
        init_anim.Looped = false
        init_anim:Play(0.02)

        init_anim.Ended:Wait()

        local unequipped_anim = animator:LoadAnimation(status:WaitForChild("ClawsUnequipped"))
        status_anim = unequipped_anim
        unequipped_anim.Looped = true
        unequipped_anim:Play(0.02)
        
        plr.PlayerGui:WaitForChild("ClawsUnequipped").Enabled = true
        plr.PlayerGui:WaitForChild("ClawsEquipped").Enabled = false
        
    end
end)

Output is attached

#

It says (x5), because I was spamming the button and it has a 3 second debounce

#

The bool value equipped is not changed inside of the function

#

that is the issue

brittle moss
#

looks like you never set equipped to true when equipping, or to false when unequipping.

north knoll
#

lol