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

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

Asked by 7 years ago
Edited 7 years ago

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.

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. XAXA 1569 — 7y
0
Yeah. Where'd you even find GetObject()? I don't find it on the wiki. hiimgoodpack 2009 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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)
Ad

Answer this question