Hi folks, I’m trying to make mobile buttons for my fighting games and two of those are hold buttons, However for some reason no matter what I seem to do the buttons don’t let go when you lift it. I tried almost everything in my head like detecting if it’s lifted off.
Code:
function buttonpunch()
if cd == false then
cd = true
print("Threw fist")
game.ReplicatedStorage.punch:FireServer(left,game.Players.localPlayer.Character)
wait(0.7)
cd = false
end
end
function buttonblock(a,inputstate,e)
if cd == false then
if inputstate == Enum.UserInputState.Begin then
cd = true
blocking = true
print("Blocking")
game.ReplicatedStorage.block:FireServer(game.Players.localPlayer.Character,blocking)
end
if inputstate == Enum.UserInputState.Cancel and inputstate == Enum.UserInputState.End then
print("Unblocked")
blocking = false
cd = false
game.ReplicatedStorage.block:FireServer(game.Players.localPlayer.Character,blocking)
end
end
end
function buttonrun(a,inputstate,e)
if cd == false then
if inputstate == Enum.UserInputState.Begin then
cd = true
sprint = true
print("Running")
game.ReplicatedStorage.roll:FireServer(sprint,game.Players.localPlayer.Character,blocking)
end
if inputstate == Enum.UserInputState.Cancel or inputstate == Enum.UserInputState.End then
sprint = false
cd = false
game.ReplicatedStorage.roll:FireServer(sprint,game.Players.localPlayer.Character)
end
end
end
context:BindAction("Punch",buttonpunch,true,Enum.KeyCode.E)
context:BindAction("Block",buttonblock,true,Enum.KeyCode.Q)
context:BindAction("Sprint",buttonrun,true,Enum.KeyCode.LeftShift)
context:SetPosition("Sprint", UDim2.new(1, -70, 0, 10))
context:SetPosition("Block", UDim2.new(1, -120, 0, 10))```