So i was writing some lines of code and it all worked fine until this point. So basically what happens is that instead of the function being triggered after pressing/letting go of the R Key it doesn’t trigger, instead it’s fired by pressing the wrong key, I don’t see what’s wrong with the code and i’m starting to think the code was reversed to some point but it doesn’t show it to me… Heres some of the code:
function hpcharge() -- charge function
local bools = Player.Bools
local chargeval = bools.HeavyPunchCharge
if chargeval.Value > 0 and chargeval.Value < 11 then
if hpcharging == false then
hpcharging = true
spawn(function()
wait(5)
if hpcharging == true then
hpcharging = false
end
end)
while wait(.5) and hpcharging == true and chargeval.Value > 0 do
if chargeval.Value < 11 then
chargeval.Value = chargeval.Value + 1
if chargeval.Value == 10 and hpcharging == true then
hpcharging = false
hpcharging:FireServer()
end
end
end
end
end
end
function hprelease() -- release function
local bools = Player.Bools
local chargeval = bools.HeavyPunchCharge
if hpcharging == true and chargeval.Value > 0 then
hpcharging = false
hpremote:FireServer()
end
end
UIS.InputBegan:Connect(function(input,IsTyping)
if IsTyping then
return
elseif input.KeyCode == Enum.KeyCode.R then
if Player.Character:FindFirstChild("StarPlatinum") then
hpcharge() -- function is triggered after pressing the key
end
end
end)
UIS.InputEnded:Connect(function(input,IsTyping)
if IsTyping then
return
elseif input.KeyCode == Enum.KeyCode.R then
if Player.Character:FindFirstChild("StarPlatinum") then
hprelease() -- function is triggered after letting go of the key
end
end
end)
I don’t know what’s wrong with the code, if im doing something wrong or anything because it only triggers when the player presses E which weirdly is another function triggering event, but there is nothing related to the lines of code above on it. Can someone please review the code and tell me what’s wrong?
Nono, you got it mixxed up, what i’m trying to find a solution for is the functions not being triggered by pressing R (what i’m trying to make it do) but instead it is triggered by pressing the wrong key (E). That is the problem, everything works fine on the Enum.Keycode.E…
function barragestart()
if Character:FindFirstChild("StarPlatinum") then
if bardeb == false and baractive == false then
bardeb = true
candesummon = false
barremote:FireServer(baractive)
end
end
end
UIS.InputBegan:Connect(function(input,IsTyping)
if IsTyping then
return
elseif input.KeyCode == Enum.KeyCode.E then
if Player.Character:FindFirstChild("StarPlatinum") then
barragestart()
end
end
end)
This works completely fine, but it triggers the other function… there is nothing related to that other function though… that’s what im confused about…