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

How to make a script spawn in objects from replicated storage into workspace?

So far this is the script i have.

local player = game:GetService("Players").LocalPlayer
local replicatedStorage = game:GetService("ReplicatedStorage")
local mouse = player.GetMouse()

mouse.Button1Down:Connect(function()
	game.Workspace.GetObject(replicatedStorage.FindFirstChild("Part"))
end)

This is a local script placed in the player's starter pack. Is there a way to spawn in the part at a position where i want it? The Part won't even spawn in. I want the code to have the part be cloned and spawn in the sky when the player left clicks. I have not attempted the clone part yet, as I need to make sure one block can spawn.

2 comments

1

.GetObject() is not a method of Workspace. The first step in accomplishing this would probably be to 1. Clone the part from ReplicatedStorage, then 2. Parent the clone to workspace.

0

Yeah. Where'd you even find GetObject()? I don't find it on the wiki.

1 answer

I think this is what you want.

local player = game:GetService("Players").LocalPlayer
local replicatedStorage = game:GetService("ReplicatedStorage")
local mouse = player:GetMouse()
local p001 = replicatedStorage.Part



mouse.Button1Down:Connect(function()
   p001:clone().Parent = game.Workspace
end)

I don't really understand what you want besides cloning a block in the sky, however I made this just incase you wanted it to be cloned to wherever you click.

local player = game:GetService("Players").LocalPlayer
local replicatedStorage = game:GetService("ReplicatedStorage")
local mouse = player:GetMouse()
local prt = replicatedStorage.Part




mouse.Button1Down:Connect(function()
   	local p001 = prt:Clone()
	p001.Parent = workspace
	p001.Position = ms.Hit.p
end)

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