I learnt to code random positions from a Youtube video. Then, I applied it to make my model fall from random positions. Disappointingly, the grapes only lined up. DM on discord Starlight#7272 if you want more details. This is my code:
local Grape = game.ReplicatedStorage:WaitForChild('Grape') local grapeHeight = 100 local MinX = -100 local MaxX = 100 local MaxZ= 100 local MinZ = -100 math.randomseed(tick()) local function grape() local GrapeCopy = Grape:Clone() local x = math.random(MinX,MaxX) local z math.random(MinZ,MaxZ) GrapeCopy.Parent = workspace GrapeCopy.CFrame = CFrame.new(x,grapeHeight,z) game:GetService('Debris'):AddItem(GrapeCopy,math.random(10,15)) while true do grape() wait(1) end
Could anyone explain why it is not working?
Not sure why that one didn't work, but I re-wrote that script into a shorter version and it works perfectly fine.
Here is what I did.
local minX = -100 local maxX = 100 local norY = 100 local minZ = -100 local maxZ = 100 while wait(1) do math.randomseed(tick()) local grape = game:GetService("ReplicatedStorage"):WaitForChild("Grape"):Clone() grape.Parent = game:GetService("Workspace") grape.CFrame = CFrame.new(math.random(minX,maxX),norY,math.random(minZ,maxZ)) game:GetService("Debris"):AddItem(grape,math.random(10,15)) end
I recommend putting math.randomseed(tick())
inside of the function so it randomizes every time.
I just compiled it down into less code is about it, and it works. It ranges from -100 to 100, and does not go into a straight line.
Hope this helped!