Well my problem is that when pressing the “C” on the keyboard, the following script detects it, and then changes a stringValue to true, and that true should be detected by activating the crouch animation, if it changes to true but does not do the animation, and pressing again does not change the value to false either.
local UserInput = game:GetService("UserInputService")
local Running = false
local WalkSpeed = game.Players.LocalPlayer.PlayerGui.Configuracion:WaitForChild("WalkSpeed").Value
local Player = script.Parent
local take = script:WaitForChild("Take")
local Crouch = game:WaitForChild("ReplicatedStorage"):WaitForChild("JuegoConfg"):WaitForChild("Crouch")
local Crouchidle = game:WaitForChild("ReplicatedStorage"):WaitForChild("JuegoConfg"):WaitForChild("Crouchidle")
game.Players.LocalPlayer.PlayerGui.Configuracion.WalkSpeed:GetPropertyChangedSignal("Value"):Connect(function()
WalkSpeed = game.Players.LocalPlayer.PlayerGui.Configuracion.WalkSpeed.Value
end)
local KeyText = "C"
local AgacharseKey = game.Players.LocalPlayer:WaitForChild("Keys"):WaitForChild("AgacharseKey")
AgacharseKey:GetPropertyChangedSignal("Value"):Connect(function()
KeyText = AgacharseKey.Value
end)
UserInput.InputBegan:Connect(function(key)
if (key.KeyCode.Name == KeyText) then
if not Running then
Running = true
--poner animacion
if take.Value == 'false' and script.Anim.Value == 'false' then
script.Anim.Value = 'true'
take.Value = 'true'
local flip = Crouch:Clone()
flip.Parent = script
local animloader2 = script.Parent:WaitForChild("Humanoid"):LoadAnimation(flip)
animloader2:Play()
else
while (1) do
--desactivar animacion
wait(0.1)
if script.Anim.Value == 'false' then
animloader2:Stop()
flip:Destroy()
end
end
end
end
end
end)