Basically, I’ve checked whether or not the function is runniing more than once by printing “hello” but it only prints that and other stuff once yet it makes BOTH of my arms transparency = 0.5 and when you read the script you’ll notice how that is weird:
print("hello")
print("yes there is a closestPlayer")
local SelectionBox = Instance.new("SelectionBox")
SelectionBox.Parent = ClosestChar
if math.random(1,2) == 1 then
print("blud what")
SelectionBox.Adornee = ClosestChar["Right Arm"]
ClosestChar["Right Arm"].Transparency = 0.5
else
SelectionBox.Adornee = ClosestChar["Left Arm"]
ClosestChar["Left Arm"].Transparency = 0.5
print("blud what")
end
task.wait(0.4)
SelectionBox.Visible = false
task.wait(0.4)
SelectionBox.Visible = true
task.wait(0.4)
SelectionBox.Visible = false
This isn’t the whole script, but no there isnt anything else that does this, and i know it’s doing this exact thing because it’s also making the selectionbox go on and off on both arms when it should just be created on one random arm and go on and off
local knockback = require(game.ReplicatedStorage.Modules.Knockback)
local stun = require(game.ReplicatedStorage.Modules.Stun)
local taskFunc = nil
local WallFunc = nil
local WallEndFunc = nil
game.ReplicatedStorage.Remotes.Barrier.OnServerEvent:Connect(function(plr, event)
local char = plr.Character
local hrp = char.HumanoidRootPart
if char:GetAttribute("Stunned") then return end
if event == "BarrierWall" then
if WallEndFunc then
task.cancel(WallEndFunc)
end
WallEndFunc = task.delay(1, function()
char:SetAttribute("Endlag", false)
end)
local Barrier = Instance.new("Part", workspace.Effects)
Barrier:SetAttribute("Ability", true)
Barrier.CanCollide = false
Barrier.Anchored = false
Barrier.Transparency = 0.5
Barrier.BrickColor = BrickColor.new("Baby blue")
Barrier.CFrame = hrp.CFrame * CFrame.new(0,0,-4)
Barrier.Size = Vector3.new(13, 11, 2)
local filtered = {char}
local params = OverlapParams.new()
params.FilterType = Enum.RaycastFilterType.Exclude
params.FilterDescendantsInstances = filtered
local att = Instance.new("Attachment", Barrier)
local lv = Instance.new("LinearVelocity", Barrier)
lv.Attachment0 = att
lv.MaxForce = math.huge
lv.VectorVelocity = Barrier.CFrame.LookVector * 30
local connection = nil
connection = game:GetService("RunService").Stepped:Connect(function()
local results = workspace:GetPartBoundsInBox(Barrier.CFrame, Barrier.Size, params)
for i,v in results do
if v.Parent:FindFirstChild("Humanoid") and not v.Parent:GetAttribute("Defensive") and not table.find(filtered, v.Parent) then
table.insert(filtered, v.Parent)
v.Parent:FindFirstChild("Humanoid").Health -= 12
knockback.Knockback(v.Parent.HumanoidRootPart, Vector3.new(0,35,0), v.Parent.HumanoidRootPart.RootAttachment)
stun.Stun(v.Parent:FindFirstChild("Humanoid"), 1)
end
end
end)
game:GetService("Debris"):AddItem(Barrier, 10)
if WallFunc then
task.cancel(WallFunc)
end
WallFunc = task.delay(10, function()
connection:Disconnect()
end)
elseif event == "BarrierRemove" then
local STUDS_MAX = 30
print("sent")
local ClosestChar: Model = nil
for i,v in game.Players:GetPlayers() do
v = v.Character
if v:GetAttribute("BarrierRemoved") or v == char then print("bro what") continue end
print((v.HumanoidRootPart.Position - hrp.Position).Magnitude)
if not ClosestChar and (v.HumanoidRootPart.Position - hrp.Position).Magnitude <= STUDS_MAX then
print("yesir1")
ClosestChar = v
else
if ClosestChar then
if (ClosestChar.HumanoidRootPart.Position - hrp.Position).Magnitude > (v.HumanoidRootPart.Position - hrp.Position).Magnitude and (v.HumanoidRootPart.Position - hrp.Position).Magnitude <= STUDS_MAX then
print("yesir2")
ClosestChar = v
end
end
end
end
if ClosestChar then
print("hello")
print("yes there is a closestPlayer")
local SelectionBox = Instance.new("SelectionBox")
SelectionBox.Parent = ClosestChar
if math.random(1,2) == 1 then
print("blud what")
SelectionBox.Adornee = ClosestChar["Right Arm"]
ClosestChar["Right Arm"].Transparency = 0.5
else
SelectionBox.Adornee = ClosestChar["Left Arm"]
ClosestChar["Left Arm"].Transparency = 0.5
print("blud what")
end
task.wait(0.4)
SelectionBox.Visible = false
task.wait(0.4)
SelectionBox.Visible = true
task.wait(0.4)
SelectionBox.Visible = nil
if taskFunc then
task.cancel(taskFunc)
end
ClosestChar:SetAttribute("BarrierRemoved", true)
taskFunc = task.delay(10, function()
ClosestChar:SetAttribute("BarrierRemoved", false)
ClosestChar["Right Arm"].Transparency = 0
ClosestChar["Left Arm"].Transparency = 0
end)
else
print("blud there aint")
for i,v in workspace:GetDescendants() do
if v:GetAttribute("BarrierRemoved") or v == char or v.Name ~= "Dummy" then continue end
print((v.HumanoidRootPart.Position - hrp.Position).Magnitude)
if not ClosestChar and (v.HumanoidRootPart.Position - hrp.Position).Magnitude <= STUDS_MAX then
ClosestChar = v
else
if ClosestChar then
if (ClosestChar.HumanoidRootPart.Position - hrp.Position).Magnitude > (v.HumanoidRootPart.Position - hrp.Position).Magnitude and (v.HumanoidRootPart.Position - hrp.Position).Magnitude <= STUDS_MAX then
ClosestChar = v
end
end
end
end
end
if ClosestChar then
local SelectionBox = Instance.new("SelectionBox")
SelectionBox.Parent = ClosestChar
if math.random(1,2) == 1 then
SelectionBox.Adornee = ClosestChar["Right Arm"]
ClosestChar["Right Arm"].Transparency = 0.5
else
SelectionBox.Adornee = ClosestChar["Left Arm"]
ClosestChar["Left Arm"].Transparency = 0.5
end
task.wait(0.4)
SelectionBox.Visible = false
task.wait(0.4)
SelectionBox.Visible = true
task.wait(0.4)
SelectionBox.Visible = false
if taskFunc then
task.cancel(taskFunc)
end
ClosestChar:SetAttribute("BarrierRemoved", true)
taskFunc = task.delay(10, function()
ClosestChar:SetAttribute("BarrierRemoved", false)
ClosestChar["Right Arm"].Transparency = 0
ClosestChar["Left Arm"].Transparency = 0
end)
end
end
end)
I just set the last selectionbox.visible to nil instead of false and it’s worked normally 3 times in a row i dont know if thats coincidence or not, Nevermiind it stopped workiing normally again