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

How to clone an object from Replicated Storage and put it at the player's position?

I tried to make a script to clone an object from Replicated Storage and put it at the player's position. Here is my code:

local tool = script.Parent
local poz = Workspace.Data.Player.Value.Character.UpperTorso.Position
local object = game:GetService("ReplicatedStorage").GasterBlaster
local function onActivate()
	local copy = object:Clone()
	copy.Parent = game.Workspace
	copy:MoveTo(poz)
end

And this is are my objects

https://imgur.com/a/nl4O2Uv

3 answers

It looks like you're getting the object incorrectly. Try using

local object = game.ReplicatedStorage:WaitForChild("GasterBlaster")

If you want it to teleport to the players position, then try doing this:

local player = script.Parent.Parent -- Add more parents until it points to the character
local character = player.Character

Now, we use the teleport.

object.CFrame = character.HumanoidRootPart.CFrame

I hope this helped you, I did this out of pure memory, so it may not work, if it doesn't, then let me know by pinging me in the chat, or answering to my comment.

6 comments

0

It doesn't work

0

The "GasterBlaster" dosen't even apear in the workspace

0
  1. What if the object is a Model, then you should make a PrimaryPart and setprimarypartcframe
0

I have added a primary part to the gaster blaster and made it the acual primary part but still nothing

0

I completly remade the script and it works but.. I can't use it agian, only once and it doesn't go to the player. I also added a remote event becouse that was the reason why it didn't apear in the workspace

1

I forgot to implement a part of the script. You need to also use: object.Parent = game.Workspace

Try putting The script inside the serverstorage

1 comment

0

I can't since i have the script inside a tool

Ok here is the new script I made but the blaster doesn't go to the player's position

active = 1
script.Parent.Activated:Connect(function()
	if active == 1 then
		active = 0
		g = game.ReplicatedStorage.GasterBlaster:Clone()
		g.Parent = game.Workspace
		g.PrimaryPart = g.Beamer
		g:SetPrimaryPartCFrame(script.Parent.Parent["Torso"].CFrame * CFrame.new(0,0,-5) * CFrame.Angles(0.35,math.rad(180),0))
	wait(1)
	active = 1
	end
end)

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