Hi, thank you for reading. What I'm trying to do here is that when my parts are spawned, they will move to a Part. The trick is to move it to random positions away from the part. I want to move it only a couple studs. What I tried to do is use ** math.random** at line 19 but it just keeps going far away and the parts just keep spawning at the same spots. How do I do this?
local loot = game.ServerStorage.Loot:GetChildren()
local names = {"Wood", "Foil", "Nail", "File", "DuctTape", "Razor", "MetalSheet" }
while wait(.1) do
for n = 1, #names do
local currentName = names[n]
if not game.Workspace:FindFirstChild(currentName) then
for i = 1, #loot do
if loot[i] and loot[i].Name == currentName then
local lootItemToAdd = loot[i]:Clone()
lootItemToAdd.Parent = game.Workspace
if workspace.Part then
local part = workspace.Part3
if lootItemToAdd:IsA("Part") then
print "Moving a part"
lootItemToAdd.CFrame = CFrame.new(part.Position)
elseif lootItemToAdd:IsA("Model") then
print "Moving a model"
lootItemToAdd:MoveTo(part.Position * math.random(1.2,1.5),0,part.Position * math.random(1.2,5))
end
end
end
end
end
end
end
