Script rate super high

Playing the game on an actual server:

Playing the game on Roblox Studio:

why is this happening ?
could this mean that I need to turn the script into a local script?

Here’s my script:

local parent = script.Parent
local jumping = false
hum = script.Parent.Parent.Parent.Parent.Parent:FindFirstChild("Humanoid")

hum:GetPropertyChangedSignal("FloorMaterial"):Connect(function()

	--print("New value for FloorMaterial: " .. tostring(hum.FloorMaterial))

	if hum.FloorMaterial == Enum.Material.Air then

		parent.Enabled = false

	else

		parent.Enabled = true


	end

end)

while task.wait(0.02) do

	hum.Running:Connect(function(speed)
		
		local moveDirMag = hum.MoveDirection.Magnitude

		if moveDirMag > 0 and jumping == false and speed > 30 then 

			parent.Rate = 10

		else

			parent.Rate = 0


		end

	end)


end

You’re making a hum.Running connection many, many times. You should only have to make it once.

1 Like

I FEEL SO STUPID RIGHT NOW, thank you for the help :sweat_smile:

local parent = script.Parent
local jumping = false
hum = script.Parent.Parent.Parent.Parent.Parent:FindFirstChild("Humanoid")

hum:GetPropertyChangedSignal("FloorMaterial"):Connect(function()

	if hum.FloorMaterial == Enum.Material.Air then

		parent.Enabled = false

	else

		parent.Enabled = true


	end

end)

hum.Running:Connect(function(speed)

	local moveDirMag = hum.MoveDirection.Magnitude

	if moveDirMag > 0 and jumping == false and speed > 30 then 

		parent.Rate = 10

	else

		parent.Rate = 0


	end

end)

here’s the new script working if anybody is curious.