I'm trying to use a local script that uses a bool value in my Player's stats (created with a data store) that determines if they are in battle or not. The script sets the humanoid properties WalkSpeed and JumpPower to 0.
local Fighting = script.Parent.Parent:WaitForChild("PlayerStats").InBattle -- Value determining whether they are in battle
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local humanoid = character.Humanoid -- I've also set to character:WaitForChild("Humanoid"), I believe there's no difference, and I don't see one.
while true do
if Fighting.Value == true then -- if they are fighting, they can't move
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
else
humanoid.WalkSpeed = 16
humanoid.JumpPower = 50
end
wait(0.01)
end
end)
end)
When I run the game and set the InBattle.Value to true, nothing happens and no errors occur. I also tried running a server which didn't work. I believe I'm having trouble referencing the humanoid object to edit with my code.

2 comments
Thank you! It worked, I just needed to add inbat.Value. I appreciate the help!
I added inbat.Value to the if statement by the way.