How you write ->1 in Scripts
minus a value greater than one?
I making a script that makes the player slow down based on damage
so i want if the damage taken >1 then the humanoids walkspeed goesdown
What does this mean?
If you are asking how to subtract a number if it’s greater than 1 then you could do
if value > 1 then
value = value - number
end
if you are asking how to subtract a random value greater than 1 it would be
value = value - math.random(1,highest_number)
You mean this?
if -value > 1 then
// Code here
end
If you’re talking about decreasing the value if it’s higher than 1 there are 2 ways:
if value > 1 then value -= decrease end
or
value = (value > 1) and value -= decrease
if (value - decrease) > 1 then
end
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local oldHealth = humanoid.Health
humanoid.HealthChanged:Connect(function(newHealth)
if oldHealth - newHealth > 1 then
humanoid.WalkSpeed -= 1
task.delay(1, function()
humanoid.WalkSpeed += 1
end)
end
oldHealth = newHealth
end)
I assume this is the kind of behavior you’re trying to achieve.