Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is this Instance.new script not working?

Asked by 9 years ago
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

Log in to vote
1
Answered by 9 years ago

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

0
I always make errors like that. I'm bad at proof reading. Lightdrago 95 — 9y
0
Also, it still only creates one block and then stops. Lightdrago 95 — 9y
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" ipiano 120 — 9y
0
I did that, and now it doesn't do anything at all again. Lightdrago 95 — 9y
0
("") Put part in there ITSolarWinds 25 — 9y
Ad
Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

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)

0
Solar already said that. Also, I know that. I just messed up. Lightdrago 95 — 9y
1
When i started typing he had not said it. No reason to downvote my post. Perci1 4988 — 9y
0
I didn't downvote it. Lightdrago 95 — 9y
Log in to vote
0
Answered by 9 years ago

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.

Log in to vote
-1
Answered by
Subbix -5
9 years ago

Instance.new("Part",Workspace)

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/ Subbix -5 — 9y
Log in to vote
-2
Answered by
IcyEvil 260 Moderation Voter
9 years ago
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

Answer this question