I am making a script where when the player jumps or walks it will give them a separate badge. Enum.HumanoidStateType.Running does not work and it only detects jumping instead of running. Enum.HumanoidStateType.Jumping works it is just the Running that does not work. If you can help me on this I will be happy. Here is the script that fires the server:
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local jumpEvent = ReplicatedStorage:WaitForChild("PlayerJumped")
local walkEvent = ReplicatedStorage:WaitForChild("PlayerWalked")
humanoid.StateChanged:Connect(function(oldState, newState)
if newState == Enum.HumanoidStateType.Jumping then
jumpEvent:FireServer()
end
end)
humanoid.StateChanged:Connect(function(oldState2, newState2)
if newState2 == Enum.HumanoidStateType.Running then
walkEvent:FireServer()
end
end)
Here is the script that gives the player the badge and prints message:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BadgeService = game:GetService("BadgeService")
local jumpEvent = ReplicatedStorage:WaitForChild("PlayerJumped")
local walkEvent = ReplicatedStorage:WaitForChild("PlayerWalked")
local badgeId = 605353278780244
local badgeId2 = 3931971660527702
jumpEvent.OnServerEvent:Connect(function(player)
print("Player Jumping")
if not BadgeService:UserHasBadgeAsync(player.UserId, badgeId) then
BadgeService:AwardBadge(player.UserId, badgeId)
end
end)
walkEvent.OnServerEvent:Connect(function(player)
print("Player Walking")
if not BadgeService:UserHasBadgeAsync(player.UserId, badgeId2) then
BadgeService:AwardBadge(player.UserId, badgeId2)
end
end)