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

Does anyone have any idea how I can make a part spawn on a part but not out of it?

Asked by 5 years ago

So im trying to make a script where Im going to do a loop of while true do and will spawn parts Instance.new(Part,workspace) but will not spawn out of a part

the part can be any size but is there any way i can make it so that I don't need to know the parts size in the script to do it?

0
newPart.CFrane = part.CFrame - is that what you mean? hellmatic 1523 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

I don't really get what you mean. I'm guessing that when you make a loop that spawns parts in a ServerScript, the part spawns on top of the Part1 Instance.

If you're using a LocalScript, you should have a RemoteEvent inside ReplicatedStorage so that both sides can access it. Put a ServerScript in Workspace or ServerScriptService with the code below, but use the OnServerEvent event, then put the code below in that event. Insert a LocalScript inside any Client/Player Services. In that script, locate the event, and use the FireServer function to fire it.

I might have a script for you:

local part = workspace.Part1 -- your part instance in the workspace that you're having trouble with

while wait(1) do -- loop runs every second
    local otherPart = Instance.new("Part") -- creates a new part
    otherPart.Parent = workspace -- parents the part to the part in the workspace

    otherPart.Anchored = true -- sets the part so that it won't move
    otherPart.CanCollide = false -- sets the part so anything can go through it

    otherPart.Position = part.Position -- sets the created part's position to the part in the workspace
end

-- Hopefully this script helps! Feel free to costomize it if you want!
Ad
Log in to vote
-1
Answered by 5 years ago
Edited 5 years ago

Like this?

local Part = game.Workspace.Part1
local YPOS = 0

wait ()
while true do
    wait ()
    local Part2 = Instance.new("Part", workspace)
    YPOS = YPOS + Part.Size.Y
    Part2.Size = Vector3.new(Part.Size.X, Part.Size.Y, Part.Size.Z)
    Part2.Position = Vector3.new(Part.Position.X, Part.Position.Y + YPOS, Part.Position.Z)
    Part2.Anchored = true
end

The part size is automatically detected so you do not have to insert it

Answer this question