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 using a remote event into the player using remote event?

Hi! I want to clone a BoolValue so its parent is the Player

-- server script
game.ReplicatedStorage.CopyInGameValue.OnServerEvent:Connect(function()
local original = game.ServerStorage.InGame
local copy = original:Clone()

copy.Parent = game.Players:FindFirstChild()

print("copied")

end)



-- Local Script
game.ReplicatedStorage.CopyInGameValue:FireServer()

The error says 01:21:00.418 - Argument 1 missing or nil

1 answer

Before we start, I recommend you to make your code inline, so it is easier to read. But, I will not inline it, because you have not.

--Server Script

local CopyInGameValue = game:GetService("ReplicatedStorage"):WaitForChild("CopyInGameValue")
local original = game.ServerStorage.InGame
local copy = original:Clone()
copy.Parent = game.Players:FindFirstChild() or game.Players.LocalPlayer
print(copy.Parent)
if copy.Parent = game.Players.LocalPlayer or game.Players:FindFirstChild() then
    print("yep")
    end
end)

--Local script

game.ReplicatedStorage.CopyInGameValue:FireServer()

So I think most likely the problem is, is that the () in FindFirstChild, there should be something in those parenthesis. That's why, if that won't work, I added an or to make sure it would still work. I also added printing to make sure that the script works. If it does and you want to remove the printing, deleting everything from if copy.Parent to end (The end after the print('yep')

If this helped you out, be sure to accept the answer!

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