#Animation Overlapping and not playing properly

1 messages · Page 1 of 1 (latest)

midnight valve
#
local gun = script.Parent

local idle = script.Idle
local ready = script.Ready

local readyV = gun.Handle.Ready.Value

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:FindFirstChild("Humanoid")
local animator = hum:FindFirstChild("Animator")

local uis = game:GetService("UserInputService")

local idleTrack = animator:LoadAnimation(idle)
local readyTrack = animator:LoadAnimation(ready)

function Equipped()
    idleTrack:Play()
end

function UnEquipped()
    idleTrack:Stop()
end

uis.InputBegan:Connect(function(input, gp)
    if not gp then
        if input.KeyCode == Enum.KeyCode.F then
            if char:FindFirstChild(tostring(gun)) then
                if readyV == false then
                    readyV = true
                    readyTrack:Play()

                elseif readyV == true then
                    readyV = false
                    readyTrack:Stop()
                end
            end
        end
    end
end)


gun.Equipped:Connect(Equipped)
gun.Unequipped:Connect(UnEquipped)```
drowsy turtle
#

U also have to stop the ready track when unequipping

midnight valve
#

But why are they overlapping

midnight valve
drowsy turtle
midnight valve
#

isnt it supposed to overide one another

drowsy turtle
#

Not sure, i honestly havent really worked a lot with animation

midnight valve
#

I somewhere that if its an action they override

midnight valve
#

@drowsy turtle hey

#
local gun = script.Parent.Parent

local getMouseEvent = game.ReplicatedStorage.Events.Guns.GetMousePosition

local sounds = gun.Handle.Sounds
local fireSound = sounds.FireSound

local debounce = false

gun.Activated:Connect(function()
    if debounce == false then
        debounce = true
        fireSound:Play()

        local player = game.Players:FindFirstChild(gun.Parent.Name)
        local rayOrigin = gun.Handle.RayOrigin.WorldPosition
        local mousePos = getMouseEvent:InvokeClient(player)
        local direction = (mousePos - rayOrigin).Unit * 300

        local raycastParams = RaycastParams.new()
        raycastParams.FilterType = Enum.RaycastFilterType.Exclude

        raycastParams.FilterDescendantsInstances = {
            workspace[player.Name],
        }

        local raycast = workspace:Raycast(rayOrigin, direction, raycastParams)

        if raycast then
            local hum = raycast.Instance.Parent:FindFirstChild("Humanoid")
            if hum and hum.Health > 0 then
                hum.Health -= 20
                print("Health: "..hum.Health)
            end

        end
        task.wait(.1)
        debounce = false
    end
end)```
#

Any idea why i keep shooting my self

#

i made the parameters to not shoot my self

#

in my test script it works fine

#

and i just copied the exact script from there but it doesnt work now

drowsy turtle
#

I have got no clue

midnight valve
#

damn