You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? I just wanna generate some cactus.
- What is the issue? The player and the server sees different things.
- What solutions have you tried so far? Changing the amount of time each cactus spawns to check if it was a lag issue.
This is the players view. All the cactus is anchored in the sky.
This is the servers view. All of the cactus is anchored on the ground.
local Cactus1 = game.ReplicatedStorage.Cactus1.Cactus1
local Cactus2 = game.ReplicatedStorage.Cactus2.Cactus2
local CactiNumberOnMap = 0
print(CactiNumberOnMap)
local NumberToGenerate = 500
while wait(0.12) do
if CactiNumberOnMap <= NumberToGenerate then
CactiNumberOnMap = CactiNumberOnMap + 1
local RandomX = math.random(-1023.5, 1023.5)
local RandomZ = math.random(-1023.5, 1023.5)
local RandomRotation = math.random(-180,180)
local RandomSize = math.random(1,10)
RandomSize = RandomSize/10
local OneOrTwo = math.random(1,2)
if OneOrTwo == 1 then
local Clone = Cactus1.Parent:Clone()
Clone.Parent = workspace
Clone.Cactus1.Position = Vector3.new(RandomX, 16.117, RandomZ)
Clone.Cactus1.Rotation = Vector3.new(0, RandomRotation, 0)
Clone:ScaleTo(RandomSize)
Clone.Cactus1.Touched:Connect(function(hit)
if hit.Name == "Baseplate" then -- replace this with your baseplate's name
Clone.Cactus1.Anchored = true
end
end)
elseif OneOrTwo == 2 then
local Clone = Cactus2.Parent:Clone()
Clone.Parent = workspace
Clone.Cactus2.Position = Vector3.new(RandomX, 16.117, RandomZ)
Clone.Cactus2.Rotation = Vector3.new(0, RandomRotation, 0)
Clone:ScaleTo(RandomSize)
Clone.Cactus2.Touched:Connect(function(hit)
if hit.Name == "Baseplate" then -- replace this with your baseplate's name
Clone.Cactus2.Anchored = true
end
end)
end
else
local Time = workspace.Time:GetAttribute("Time")
print("Done", Time)
break
end
end