Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is this Instance.new script not working?

while true do
		local y = math.random(21,25)
		local x = math.random(-227.7,-222.2)
		local z = math.random(0,5.2)
		s = Instance.new("Part")
		s.Parent = Workspace
		s.Size = 1,1,1
		s.TopSurface = 1
		s.BottomSurface = 1
		s.BrickColor = BrickColor.new("Bright blue")
		s.Anchored = true
		s.CanCollide = false
		s.Position = Vector3.new(x,y,z)
		s.Name = Part
		s:remove()
	wait(1)
end

Whenever I run or play solo, it does not create any parts at all. Nothing happens.

5 answers

✓ Accepted answer

1 s.Size = Vector3.new(1,1,1) It won't understand how big the block should be so...... It can't create it!

5 comments

0

I always make errors like that. I'm bad at proof reading.

0

Also, it still only creates one block and then stops.

0

You need to make Part be in quotes on line 15. You are setting the name to a string value. So s.Name = "Part"

0

I did that, and now it doesn't do anything at all again.

0

("") Put part in there

Please include any output you got. Here, it's easy to see the problem, but you still should have included the output.

Size is a vector3 value. Therefore, s.Size = Vector3.new(1,1,1)

3 comments

0

Solar already said that. Also, I know that. I just messed up.

1

When i started typing he had not said it. No reason to downvote my post.

0

I didn't downvote it.

Here's a fixed version of your script.

while true do
        y = math.random(210,250)/10
        x = math.random(-2277,-2222/10)/10
        z = math.random(0,52)/10
        s = Instance.new("Part")
        s.Parent = Workspace
        s.Size = Vector3.new(1,1,1)
        s.TopSurface = "Smooth"
        s.BottomSurface = "Smooth"
        s.BrickColor = BrickColor.new("Bright blue")
        s.Anchored = true
        s.CanCollide = false
        s.CFrame = CFrame.new(x,y,z)
        s.Name = "Part"
		wait(1)
        s:Destroy()
end

As to my knowledge, you can't look up decimals with math.random, unless you divide it by something. I changed TopSurface and BottomSurface to smooth. s.Name needs "" around the name, also it's named Part by default. You had the wait(1) after the s.remove(), which I changed to destroy(). Size needed to be a Vector3 with () and instead of position, I used CFrame.

Instance.new("Part",Workspace)

1 comment

0

No reason to downvote me since im actually trying to help. I know most of you are trollers thats just going to get you down votes. Thanks for listening/

while true do
        local y = math.random(21,25)
        local x = math.random(-227.7,-222.2)
        local z = math.random(0,5.2)
        s = Instance.new("Part")
        s.Parent = game.Workspace
        s.Size = Vector3.new(1,1,1)
        s.TopSurface = 1
        s.BottomSurface = 1
        s.BrickColor = BrickColor.new("Bright blue")
        s.Anchored = true
        s.CanCollide = false
        s.Position = Vector3.new(x,y,z)
        s.Name = "Part"
        s:remove()
    wait(1)
end

This discussion is preserved as it was. New answers, comments, and votes are closed.