You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
- I made a cheap but reliable ability/skill system. I want it so that the player can only use abilities when grounded (with some exceptions to certain abilities)
- What is the issue? Include screenshots / videos if possible!
- I feel like Ive done everything I could try. I tried checking the HumanoidStateType, but Im not sure what Im doing wrong. No matter what I tried, the player could still fire the event for the ability in the air.
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
- Stated above. If you need me to post the codes I tried after this one then let me know.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
First Attempt
local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
local plr = game:GetService("Players").LocalPlayer
local hum = plr.CharacterAdded:Wait():FindFirstChild("Humanoid")
local abilityCall = RS.Remotes.AbilityRemotes
local trigger = "E"
local cooldown = 1
local db = false
UIS.InputBegan:Connect(function(input, gpe)
if gpe then return end
if input.KeyCode == Enum.KeyCode[trigger] and db == false then
if plr:GetAttribute("CharID") == 1 then
db = true
abilityCall.Tornado:FireServer()
task.wait(cooldown)
db = false
end
end
end)
Second Attempt
local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
local plr = game:GetService("Players").LocalPlayer
local hum = plr.CharacterAdded:Wait():FindFirstChild("Humanoid")
local abilityCall = RS.Remotes.AbilityRemotes
local trigger = "E"
local cooldown = 1
local db = false
local function InAir()
if hum then
return hum:GetState() == Enum.HumanoidStateType.Freefall or hum:GetState() == Enum.HumanoidStateType.Jumping
end
return false
end
hum.StateChanged:Connect(function(_, newState)
if newState == Enum.HumanoidStateType.Freefall or newState == Enum.HumanoidStateType.Jumping then
print("in the air")
else
print("not in the air")
end
end)
-- Initial check
if InAir() then
print("in the air")
else
UIS.InputBegan:Connect(function(input, gpe)
if gpe then return end
if input.KeyCode == Enum.KeyCode[trigger] and db == false then
if plr:GetAttribute("CharID") == 1 then
if plr:GetState() ~= Enum.HumanoidStateType.Freefall or hum:GetState() ~= Enum.HumanoidStateType.Jumping then
db = true
abilityCall.Tornado:FireServer()
task.wait(cooldown)
db = false
end
end
end
end)
end
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.