local obbyNames = {"Obby 1", "Obby 2", "Obby 3", "Obby 4", "Obby 5", "Obby 6", "Obby 7", "Obby 8", "Obby 9", "Obby 10", "Obby 11", "Obby 12", "Obby 13", "Obby 14", "Obby 15", "Obby 16"}
local lastObbyPosition = Vector3.new(0, 0, 0)
local offset = Vector3.new(0, 0, 10)
local touchPart = nil
local lastTouchPartSize = Vector3.new(4,1,4.3)
createTouchPart = function(position, size)
if touchPart then
touchPart:Destroy()
wait(0.3)
end
touchPart = Instance.new("Part", workspace)
touchPart.Anchored = true
touchPart.Position = position
touchPart.Size = size
touchPart.CanCollide = false
touchPart.Transparency = 1
touchPart.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
-- Call this function again to reset the touchPart
local random = math.random(1, #obbyNames)
local obby = game.ReplicatedStorage[obbyNames[random]]:Clone()
createTouchPart(lastObbyPosition, lastTouchPartSize)
obby.Parent = workspace
if obby then
obby:SetPrimaryPartCFrame(CFrame.new(lastObbyPosition) * CFrame.new(offset))
lastObbyPosition = obby.Touch.Position
if obby.Touch.Size then
lastTouchPartSize = obby.Touch.Size
end
obby.Touch.Touched:Connect(function()
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player and not obby.Touch:FindFirstChild(player.Name) then
local touchValidation = Instance.new("BoolValue")
touchValidation.Name = player.Name
touchValidation.Parent = obby.Touch
player.leaderstats.Obbies.Value += 1
end
end)
end
wait(0.5)
end
end)
end
createTouchPart(Vector3.new(-0.687, 0, -9.595), Vector3.new(23.004, 1, 27.007))
This is infinite obby script. If player touches “Touch” part in Obby, new obby gets spawned
if player and not obby.Touch:FindFirstChild(player.Name) then
local touchValidation = Instance.new("BoolValue")
touchValidation.Name = player.Name
touchValidation.Parent = obby.Touch
player.leaderstats.Obbies.Value += 1
In here, if player touches “Touch” part, value to “Obbies” gets added. Problem is, if another player already touched that part, other player who also touches that part doesnt get value increased.