I am trying to make a part that has a 50% chance of spawning a wood on it's position, but when I copy more of the blocks and start the game it just spawns on all of them or on none, no erros, and I have no idea how would I fix it
The block is just a half transparent part with a single script in it, the wood is in replicatedstorage
math.randomseed(tick()) local random = math.random(1,400) if random > 1 and random < 200 then local wud = game.ReplicatedStorage.Wood:Clone() wud.Parent = game.Workspace wud:MoveTo(script.Parent.Position) elseif random > 200 and random < 400 then print("nothing") end script.Parent:Destroy()
You dont nescesarily need to add :MoveTo
you could just change the position via Explorer or just change it in the script. I used Instance.new()
to show you the point. Also If you are doing a 50% chance, you should use a range of 1,2
Here is an example
local random = math.random(1,2) local debounce = false bool = true while bool == true do print(random) if random == 1 and debounce == false then local wud = Instance.new('Part') wud.Transparency = .5 wud.Position = Vector3.new(-88.89, 0.5, 36.11) -- Change Pos wud.BrickColor = BrickColor.new('Brown') wud.Parent = game.Workspace debounce = true wait(2) debounce = false elseif random == 2 and debounce == false then print("nothing") debounce = true wait(2) debounce = false end end
Some Error Reasons -