I have a system that I fear might not work so well.
Basically, let’s say I inflict a player with Slowness that lowers the affected player’s walkspeed by 25%, but then they get inflicted with Stunned Ⅰ, which lowers the affected player’s walkspeed by 75%.
When the status effect completes its lifetime, it’ll revert the changes back to the original walkspeed that it saves before the effect happens. This means Stunned Ⅰ conflicts with Slowness, and I’m guessing once Stunned Ⅰ ends, it’ll save the affected walkspeed that was caused by Slowness.
Slowness Code
local Target = script.Parent.Target
local Activated = script.Parent.Activated
local SavedWP = 0
local SavedSS = 0
function Effect()
local char = Target.Value
local Humanoid = char:FindFirstChildWhichIsA("Humanoid")
local WalkSpeed = char:GetAttribute("WalkSpeed")
local SprintSpeed = char:GetAttribute("SprintSpeed")
SavedWP = WalkSpeed
SavedSS = SprintSpeed
local AffectedSS = (SprintSpeed - (SprintSpeed * .25))
local AffectedWS = (WalkSpeed - (WalkSpeed * .25))
char:SetAttribute("WalkSpeed",AffectedWS)
char:SetAttribute("SprintSpeed",AffectedSS)
end
function RevertChanges()
local char = Target.Value
local WalkSpeed = char:GetAttribute("WalkSpeed")
local SprintSpeed = char:GetAttribute("SprintSpeed")
local Humanoid = char:FindFirstChildWhichIsA("Humanoid")
char:SetAttribute("WalkSpeed",SavedWP)
char:SetAttribute("SprintSpeed",SavedSS)
end
function ActivatedCheck()
if Activated.Value == true then
Effect()
elseif Activated.Value == false then
RevertChanges()
end
end
Activated:GetPropertyChangedSignal("Value"):Connect(ActivatedCheck)
Stunned Ⅰ Code
local Target = script.Parent.Target
local Activated = script.Parent.Activated
local SavedWP = 0
local SavedSS = 0
function Effect()
local char = Target.Value
local Humanoid = char:FindFirstChildWhichIsA("Humanoid")
local WalkSpeed = char:GetAttribute("WalkSpeed")
local SprintSpeed = char:GetAttribute("SprintSpeed")
SavedWP = WalkSpeed
SavedSS = SprintSpeed
local AffectedSS = (SprintSpeed - (SprintSpeed * .75))
local AffectedWS = (WalkSpeed - (WalkSpeed * .75))
char:SetAttribute("WalkSpeed",AffectedWS)
char:SetAttribute("SprintSpeed",AffectedSS)
end
function RevertChanges()
local char = Target.Value
local WalkSpeed = char:GetAttribute("WalkSpeed")
local SprintSpeed = char:GetAttribute("SprintSpeed")
local Humanoid = char:FindFirstChildWhichIsA("Humanoid")
char:SetAttribute("WalkSpeed",SavedWP)
char:SetAttribute("SprintSpeed",SavedSS)
end
function ActivatedCheck()
if Activated.Value == true then
Effect()
elseif Activated.Value == false then
RevertChanges()
end
end
Activated:GetPropertyChangedSignal("Value"):Connect(ActivatedCheck)
If you guys got any ideas or suggestions to help prevent that issue from happening.