Hey! I'm currently stuck in the programming of my game because of a script that I have to make: the goal is that when I click on the button I created, the character starts to jump and I have to wait for it to hit the ground before I can click again. I have already managed to program the script to make the character jump but I can't manage to do the one that allows me to wait for the character to touch the ground before being able to click again. Here is the script:
-- Parameters local WAIT_TIME = .5 -- Services Player = game:GetService("Players") local button = script.Parent local canActivate = true local function playerJump() if canActivate then canActivate = false local localPlayer = Player.LocalPlayer local character = localPlayer.Character local Humanoid = character:WaitForChild("Humanoid") local oldJumpPower = Humanoid.JumpPower Humanoid.JumpPower = 1 Humanoid:ChangeState(Enum.HumanoidStateType.Jumping) Humanoid.JumpPower = oldJumpPower task.wait(WAIT_TIME) canActivate = true end end button.Activated:Connect(playerJump)
I hope that someone could help me! Thanks in advance! Belox.
Hi,
Heres a script that checks whether the player is touching the floor or is in the air by identifying the floor material found in the humanoid of the player
-- by sne_123456 wait(5) while true do for i,v in pairs(game.Workspace:GetChildren()) do if v:IsA("Model") then local h = v:FindFirstChildWhichIsA("Humanoid") if h ~= nil then -- finds player print("found humanoid") if h.FloorMaterial ~= Enum.Material.Air then -- checks if hes in air or not print("Hes not jumping") else print("He jumped") end end end end wait() end
I tested it so dont tell me it doesnt work
also prepare to get your ooutput filled with thousands of prints xd