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

How to clone an object using a remote event into the player using remote event?

Asked by 5 years ago

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

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

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!

Ad

Answer this question