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

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

Asked by 3 years ago
Edited 3 years ago

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

Log in to vote
2
Answered by
2_MMZ 1059 Moderation Voter
3 years ago

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.

0
It doesn't work Lordverdeninja23 0 — 3y
0
The "GasterBlaster" dosen't even apear in the workspace Lordverdeninja23 0 — 3y
0
1. What if the object is a Model, then you should make a PrimaryPart and setprimarypartcframe sayer80 457 — 3y
0
I have added a primary part to the gaster blaster and made it the acual primary part but still nothing Lordverdeninja23 0 — 3y
View all comments (2 more)
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 Lordverdeninja23 0 — 3y
1
I forgot to implement a part of the script. You need to also use: object.Parent = game.Workspace 2_MMZ 1059 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

Try putting The script inside the serverstorage

0
I can't since i have the script inside a tool Lordverdeninja23 0 — 3y
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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)

Answer this question