1. What do you want to achieve?
– I want my script when my animation is playing and i press keybind W (must be keybind) it will do a function.
2. What is the issue? Include screenshots / videos if possible!
– server script cannot detect keybind.
local animationPlaying = true
animationTrack.Stopped:Connect(function()
animationPlaying = false
char:SetAttribute("Attacking", false)
char:SetAttribute("Morph",false)
end)
task.spawn(function()
while animationPlaying do
if char:GetAttribute("Stunned") or char:GetAttribute("Ragdoll") then
animationTrack:Stop()
local sound = script.Counter:Clone()
sound.Parent = humrp
sound:Play()
game.Debris:AddItem(sound,1)
local animationTrackK1 = animatorK:LoadAnimation(script.C1)
animationTrackK1.Priority = Enum.AnimationPriority.Action4
animationTrackK1.Looped = false
local animationTrack1 = animator:LoadAnimation(script.C2)
animationTrack1.Priority = Enum.AnimationPriority.Action4
animationTrack1.Looped = false
local dashForce = 50000
local bodyPosition = Instance.new("BodyPosition")
bodyPosition.MaxForce = Vector3.new(dashForce, 0, dashForce)
bodyPosition.Position = humrp.Position + (humrp.CFrame.LookVector * -40)
bodyPosition.P = 10000
bodyPosition.D = 1000
bodyPosition.Parent = humrp
game.Debris:AddItem(bodyPosition, 0.2)
animationTrack1:Play()
animationTrackK1:Play()
char:SetAttribute("Stunned",false)
end
UserInputService.InputBegan:Connect(function(input)
if input.Keycode == Enum.Keycode.W then
animationTrack:Stop()
local animationTrackK2 = animatorK:LoadAnimation(script.F1)
animationTrackK2.Priority = Enum.AnimationPriority.Action4
animationTrackK2.Looped = false
local animationTrack2 = animator:LoadAnimation(script.F2)
animationTrack2.Priority = Enum.AnimationPriority.Action4
animationTrack2.Looped = false
animationTrackK2:Play()
animationTrack2:Play()
local dashForce = 50000
local bodyPosition = Instance.new("BodyPosition")
bodyPosition.MaxForce = Vector3.new(dashForce, 0, dashForce)
bodyPosition.Position = humrp.Position + (humrp.CFrame.LookVector * 45)
bodyPosition.P = 10000
bodyPosition.D = 1000
bodyPosition.Parent = humrp
game.Debris:AddItem(bodyPosition, 0.2)
animationTrack2.KeyframeReached:Connect(function(key)
if key == "Hit" then
hitbox:Start()
wait(0.075)
hitbox:Stop()
hitbox:Destroy()
end
end)
end
end)
task.wait(0.05)
end
end)
AnimationTrack:Play()
3. What solutions have you tried so far?
– I did try to look for solution but i did not find one.
simple explanation of this script is an animation plays and when animation is playing and player gets an attribute stunned then it does a thing. but if player press keybind W then it does a different thing. the problem is on the detecting if player press keybind W since this is a server script.