but when the player lands, half of the time its does not print, sometimes it prints and sometimes not…/
this is the code…
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local humanoid = char:WaitForChild("Humanoid")
humanoid.StateChanged:Connect(function()
if humanoid:GetState() == Enum.HumanoidStateType.Landed then
print("Landed")
end
end)
end)
end)
Please, if someone can tell me the problem it will be helpfull
Once the character is loaded, the script will immediately check if the player is landed or not. If they are not landed by the time the script checks, the script will have ended. Try using a loop to keep checking until it has landed.
repeat
wait()
until humanoid:GetState() == Enum.HumanoidStateType.Landed
print(“Landed”)
local U = 1
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local debounce = false
local humanoid = char.Humanoid
humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
if humanoid.Jump == true then
wait(1)
if humanoid.Jump == true then
humanoid.StateChanged:Connect(function()
if humanoid:GetState() == Enum.HumanoidStateType.Landed then
if debounce == false then
debounce = true
wait(0.2)
print("Jumpin")
if player.Areas.AgilityArea.AgilityAreaMulti.Value == true then U = 5 -- 100 Agility required
else U = 1
end
local GainAgility = ((1 * player.realMultiplayers.AgilityMultiplayer.Value) * (U))
player.RealStats.Agility.Value = ((player.RealStats.Agility.Value) + GainAgility)
debounce = false
end
end
end)
end
end
end)
end)
end)
this is my full code, it need to detect if player jump for 1 second then it wait for the player to land and give him stats, it will have the same problem too?
It will only work if the player lands at exactly 1 second, else the if condition will not be true. The script would not wait until it is true and just run past it.