collide = true
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function()
for i, v in pairs(game.workspace:GetChildren()) do
if v.Name == "Swap" then
if collide == true then
v.Transparency = 1
v.CanCollide = false
collide = false
else
v.CanCollide = true
v.Transparency = 0
collide = true
end
end
end
end)
Any help would be greatly appreciated and im willing to answer any questions!
game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent").OnServerEvent:Connect(function()
for i, v in pairs(game.workspace:GetChildren()) do
if v.Name == "Swap" then
if v.CanCollide then
v.Transparency = 1
v.CanCollide = false
collide = false
else
v.CanCollide = true
v.Transparency = 0
collide = true
end
end
end
end)
You put your collide variable outside the function, causing it to be set to true/false each iteration. You want to reference the CanCollide value instead.