How to Find Player Current Walkspeed when Touching a Part (rlly need help)

Im Gonna be as Specific as Possible Im making a Script where if u touch this Part it makes Everything Unanchored but I want the player to have a Specific amount of Walkspeed I been trying to do this for 2 Hours and nothin is working and I tried this with Server Script Service to
and I have the script inside the part so rn this is what i have rn to test it before using the rest of the script
this is my current script after deleting the others that didnt work

local BrokenGlass = script.Parent.BrokenGlasses

local MainGlass = script.Parent.MainGlass

MainGlass.Touched:Connect(function(Player)

local PlayerHumanoid = Player:FindFirstChild(“Humanoid”)

if PlayerHumanoid.WalkSpeed ~= nil and PlayerHumanoid.WalkSpeed == 60 then

print(“fast”)

else

print(“not fast”)

end

end)

The .Touched event passes the part that touched it, not the player who touched it’s character. You have to get the character yourself like this

MainGlass.Touched:Connect(function(Hit)
	local Player = game.Players:GetPlayerFromCharacter(Hit)
	-- check if player exists, player has humanoid, etc

How do I get its Humanoid and its Walkspeed after I get the Player?

Player.Character:WaitForChild('Humanoid').WalkSpeed

maybe do

MainGlass.Touched:Connect(function(Hit)
local health = hit.Parent:WaitForChild("Humanoid").Walkspeed

You shouldn’t use WaitForChild here since if the player is going to be sending Touched events, they’re probably alive and well. Dot index (hit.Parent.Humanoid) should be used instead.

you could even do this

MainGlass.Touched:Connect(function(Hit)
local health = hit.Parent:WaitForChild("Humanoid").Walkspeed
print(Hit.Parent, health)

or

MainGlass.Touched:Connect(function(Hit)
local health = hit.Parent:WaitForChild("Humanoid").Walkspeed
   if health >= 16 then
--whatever you want to do
end

i made a misconception and used the word health accidentally

Yo thank u so freaking much after 4 hours of tryna do this it finally works :smiley: