-
What do you want to achieve?
I want to achieve a reliable humanoid walkspeed slow system where the longest/largest slow overrides the old one if there is one and if it’s shorter in duration. -
What is the issue?
The issue is for example, a humanoid gets slowed for 3 seconds, but they get slowed for 10 seconds while slowed for 3 seconds, their walkspeed will return to 16 after those 3 seconds and the longer stun will be scrapped. -
What solutions have you tried so far?
Tried some hotfixes with CollectionService, NumberValues and while loops but none of them are reliable.
local character = script.Parent
local collectionService = game:GetService("CollectionService")
local humanoid = character:WaitForChild("Humanoid")
local bindableEvent = Instance.new("BindableEvent")
bindableEvent.Name = "BindableEvent"
bindableEvent.Parent = character
local eventFunctions = {
["UpdateState"] = function(...)
local info = ...;
local state = info.State
local TableArguments = info.TableArguments
if state == "isSlowed" then
local SlowAmount = TableArguments.SlowAmount
humanoid.WalkSpeed = SlowAmount
local Duration = TableArguments.Duration
--dont know what to put here instead of delay
delay(Duration,function()
humanoid.WalkSpeed = 16
end)
end
end,
}
bindableEvent.Event:Connect(function(Keyword,TableArguents)
eventFunctions[Keyword](TableArguents)
end)
I can provide the rest of the code such as how it gets to the bindable event if requested but did not do it here to not flood. Any help is appreciated.