Attempt to index nil with .Parent

Hey! Title says it all…

script is in ServerScriptService:

local RE = game.ReplicatedStorage.Remotes.CloneObject

RE.OnServerEvent:Connect(function(object, destiny)
	object:Clone().Parent = destiny
end)

Here’s how I’m firing the event, trhought a localscript on the PlayerGui:

	game.ReplicatedStorage.Remotes.CloneObject:FireServer(game.ReplicatedStorage.obj01, game.Workspace)

When you clone an object and wish to edit it’s properties, its suggested to create a new variable for said clone;

RE.OnServerEvent:Connect(function(object, destiny)
	local clonedObject = object:Clone()
	clonedObject.Parent = destiny
end)
1 Like

The player is always OnServerEvent (NOT OnClientEvent)'s first argument so you need to do this instead:

RE.OnServerEvent:Connect(function(player, object, destiny)
	object:Clone().Parent = destiny
end)
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.