I have a module that handles player stamina, it works for running, jumping and other miscellaneous actions. The jump action is a bit tricky though. It does detect jumps but the issue is it can only detect them after the jump has completed. Maybe it’s a bit nit-picky but I would like it to register the jump as it’s happening.
I know I could solve this by checking via client-side but I want to perform server-sided checks so that it’s less exploitable. If anyone has a method I could try let me know.
Here is what I a doing currently:
function module.handleMovement(player)
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:FindFirstChild("Humanoid")
local jumped = false
hum.StateChanged:Connect(function(old, new)
if (old == Enum.HumanoidStateType.Freefall and new == Enum.HumanoidStateType.Running) or (old == Enum.HumanoidStateType.Freefall and new == Enum.HumanoidStateType.Landed) then
module.completeAction(player, "Jump")
end
end)
end
Roblox recommends detecting changes like that client-side, unfortunately I’m unsure of what you could do since you’re detecting those changes server-side. You could try a RemoteEvent when they jump to tell the server, but that’s about all I can recommend.
OP already said they want to do server side checks. Also please never use key systems. Server side checks and proper remote programming means you don’t need keys and exploiters can easily find the key and bypass it. Keys also inflate network usage.
The hash and keys was a joke, add a little salt into it as well. I don’t see why something as simple as a player jumping is a vulnerability, however I am not sure what OP is trying to achieve. Anything to do with the client should always be checked with the client if you want reliability.
For anyone else struggling with this here is a module I made.
I still have to do more testing but so far is seems very reliable.
local module = {}
module.HasLanded = {}
module.RegisterPlayer = function(self,player)
coroutine.wrap(function()
while true do
if player.Character then
local root = player.Character.HumanoidRootPart
local start = root.Position
local direction = -(root.CFrame.UpVector*20)
local ray = Ray.new(start,direction)
local part,hitPos = workspace:FindPartOnRay(ray,player.Character)
if (root.Position-hitPos).magnitude >= 7 then
if module.HasLanded[player] ~= false then
module.HasLanded[player] = false
print(player.Name.." has jumped")
end
else
if module.HasLanded[player] == false then
print(player.Name.." has landed")
end
module.HasLanded[player] = true
end
end
wait()
end
end)()
end
return module