local RunService = game:GetService("RunService")
local Workspace = game:GetService("Workspace")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local RadiusCreater = require(script.RadiusCreater)
local character = player.Character or player.CharacterAdded:Wait()
local hrp = character:WaitForChild("HumanoidRootPart")
local SPAWNING_PART = Workspace:WaitForChild("SpawningPart")
local SPAWN_INTERVAL = 1
local COLLECTION_RADIUS = player:GetAttribute("Radius") or 0
player:GetAttributeChangedSignal("Radius"):Connect(function()
COLLECTION_RADIUS = player:GetAttribute("Radius")
RadiusCreater.createRadius(player, COLLECTION_RADIUS)
print("Radius updated:", COLLECTION_RADIUS)
end)
local collectiblesFolder = Instance.new("Folder")
collectiblesFolder.Name = "PlayerCollectibles"
collectiblesFolder.Parent = Workspace
local spawnedParts = {}
local function spawnCollectible()
if not SPAWNING_PART or not SPAWNING_PART:IsA("BasePart") then return end
local part = Instance.new("Part")
part.Size = Vector3.new(2,2,2)
part.Anchored = true
part.CanCollide = false
part.Shape = Enum.PartType.Ball
part.Color = Color3.fromRGB(math.random(0,255), math.random(0,255), math.random(0,255))
part.Parent = collectiblesFolder
local size = SPAWNING_PART.Size
local pos = SPAWNING_PART.Position
local offset = Vector3.new(
math.random(-size.X/2, size.X/2),
size.Y/2 + part.Size.Y/2,
math.random(-size.Z/2, size.Z/2)
)
part.Position = pos + offset
table.insert(spawnedParts, part)
end
spawn(function()
while character.Parent do
spawnCollectible()
task.wait(SPAWN_INTERVAL)
end
end)```
#Code overview for exploit/improvements
1 messages · Page 1 of 1 (latest)
RunService.Heartbeat:Connect(function()
for i = #spawnedParts, 1, -1 do
local part = spawnedParts[i]
if part and hrp then
local dist = (part.Position - hrp.Position).Magnitude
if dist <= COLLECTION_RADIUS then
part:Destroy()
table.remove(spawnedParts, i)
print(player.Name .. " collected a part!")
end
end
end
end)
all one script btw
don't use ai and then ask others to work on it
im confused?
where did you get that from
as long as the code is AI, don't ask others to fix it
its not?
i wrote most of it
"most" being the variable names
are you stupid? sorry but variable names are supposed to be fully caps when they are a constant... if you didnt know that
does that mean that i can't make "guy" to be a constant
What?