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

Attempt to index nil with 'Clone'?

Hello, its me and remote events again. I am making a building game, and i want the player creations to go server-sided, the problem is that when i call this remote, the title error prints on the output. If this solves it will make saving these buildings alot easier.

Remote identifier

game.ReplicatedStorage.PlaceObject.OnServerEvent:Connect(function(plr,part,plrName)
	print(part); print(plr)
	if part == nil then
		warn("No part! part == nil")
	end
	wait(0.35)
	local CreatePart = part:Clone()
	CreatePart.Name = "Part"
	CreatePart.Parent = workspace
	CreatePart.Transparency = 0
	CreatePart.CanCollide = true

	local Property = Instance.new("StringValue")
	Property.Parent = CreatePart
	Property.Name = "Of"
	Property.Value = plrName.."'s Part"
	wait(1)
end)

Player's call: (Just a fragment of the problematic code but sure you understand.);

part = Instance.new(IsPart)
part.Parent = game.Workspace
part.Name = "ExamplePart"
part.Position = Mouse.Hit.Position
part.Anchored = true
part.Transparency = 0.6
part.CanCollide = false

Mouse.Button1Down:Connect(function()
	if EnabledToCreate and goodTOPlace then
		EnabledToCreate = false
		game.ReplicatedStorage.PlaceObject:FireServer(part, Player.Name)
		wait(1)
		EnabledToCreate = true
	end
end)

Yeah. I am not that experienced with remote events. Could you please explain what i am doing wrong?

Thanks.

2 comments

0

Please accept the answer below if you find it useful.

0

It will help others from posting additional answers

1 answer

✓ Accepted answer

Your part was created on the client, therefore, it will show up as nil on the server because it doesn't replicate.

3 comments

0

So how do i replicate it on the server so all the players are able to see the others buildings? Sorry if i am a bit annoying

0

Short Answer: You can't, make the server handle building instead of the client

0

Just found another way to do it but thanks for adding me some knowledge

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