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

instance.new not working. Can anybody identify the problem?

Asked by 2 years ago

I am creating a system which spawns blocks of ice. I have encountered a problem in which the script appears to runs through perfectly fine (no errors in the output) but does not appear to summon blocks of ice. I am not sure what to do in this situation so perhaps one of you could identify the problem?

local function newice()
    local ice = Instance.new("Part")
    local icex = math.random(5,100)
    local icey = math.random(icex/6, icex/5)
    local icez = math.random(icex/6, icex/1.3)
    local icedensity = 2.403
    local iceelasticity = 0.1
    local iceelasticityweight = 1
    local icefriction = 0.25
    local icefrictionweight = 1

    ice.Size = Vector3.new(icex,icey,icez)
    ice.Material = "Glass"
    ice.Transparency = 0.1
    ice.CustomPhysicalProperties =      PhysicalProperties.new(icedensity,iceelasticity,iceelasticityweight,icefriction,icefrictionweight)
    ice.Position = Vector3.new(math.random(-249.5+icex, 249-icex), 6565, 13346)
end

while true do --for testing purposes
    newice()
    wait(2.5)
end

1 answer

Log in to vote
0
Answered by 2 years ago

I think you forgot to parent the ice to the Workspace service

ice.Parent = game.Workspace
Ad

Answer this question