i have a script that gets cloned into multiple objects. problem is the script is meant to check is a boolvalue called debounce disabled but it only checks it once and doesn't even change the value. The only times it checks is on game start. The script is a server script running in objects in workspace.
local AttackPoint = workspace.Base
local Health = workspace.Base.Health
local Char = script.Parent
local debounce = workspace.Base.Debounce.Value
local debounceTime = 5
local raycastParams = RaycastParams.new()
local range = 10
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.FilterDescendantsInstances = {script.Parent}
while task.wait(0.1) do
local raycast = workspace:Raycast(Char.PrimaryPart.Position, (AttackPoint.Position - Char.PrimaryPart.Position).Unit * range, raycastParams)
if raycast then
local hitPart = raycast.Instance
if hitPart then
if hitPart.Name == AttackPoint.Name then
if debounce == false then
debounce = true
Health.Value -= 10
task.wait(debounceTime)
debounce = false
end
end
end
end
end