What do you want to achieve? Keep it simple and clear!
I made a script to load an animation for skill when the key Down but when the key is Key Up the animation is not stopping
-- Script Inside the ServerScript
local Event = script.Parent
local avaibleAnimationIds = {"7268865430", "7268875953", "7268878561"}
Event.OnServerEvent:Connect(function(player,active,mouseaim)
local Character = player.Character
local newAnimator = Instance.new("Animation", Character)
newAnimator.Name = "Hold_Anim"
newAnimator.AnimationId = "rbxassetid://"..avaibleAnimationIds[1]
if active == true then
local ReleaseAnim = Character:WaitForChild("Humanoid"):LoadAnimation(newAnimator) -- Creating the animation loader
ReleaseAnim:Stop()
Event:FireClient(player)
else
local ReleaseAnim = Character:WaitForChild("Humanoid"):LoadAnimation(newAnimator) -- Creating the animation loader
ReleaseAnim:Play()
newAnimator:Destroy()
end
end)
-- Script inside the Local Script
wait(1)
local UIS = game:GetService("UserInputService")
local Event= script.Event
local Player = game.Players.LocalPlayer
local character = Player.Character
if not character or not character.Parent then
character = Player.CharacterAdded:wait()
end
local Root = character:WaitForChild("HumanoidRootPart")
local mouse = Player:GetMouse()
local active = false
local debounce = false
local cooldown = 2
UIS.InputBegan:Connect(function(Input,isTyping)
if isTyping then
return
elseif Input.KeyCode == Enum.KeyCode.Z then
if debounce == false and active == false then
debounce = true
Event:FireServer(active,mouse)
end
end
end)
UIS.InputEnded:Connect(function(Input,isTyping)
if isTyping then
return
elseif Input.KeyCode == Enum.KeyCode.Z then
if debounce == true and active == false then
active = true
Root.CFrame = CFrame.new(Root.Position, Root.Position + mouse.Hit.LookVector)
Event:FireServer(active,mouse)
end
end
end)
Event.OnClientEvent:Connect(function()
wait(cooldown)
debounce = false
active = false
end)