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

Can I get some help on how to fix my placement system's clone error?

This is the error I get: ServerScriptService.ServerPlacement:2: attempt to index nil with 'Clone' And this is my script

local function Place(data, location, pos)
	local model = game.ReplicatedStorage.Models:FindFirstChild(data.Name):Clone()
	
	model.PrimaryPart.Transparency = 1
	model.PrimaryPart.CanCollide = false

	model:SetPrimaryPartCFrame(CFrame.New(pos.X, pos.Y, pos.Z) * CFrame.Angles(0, math.rad(data.CFrame.Rotation), 0))
	
	model.Part = location
end

game.ReplicatedStorage.Events.PlaceObj.OnServerEvent:Connect(Place)

3 comments

1

Instances in ReplicatedStorage may not have loaded yet, try using WaitForChild()

0

That brought this error: Infinite yield possible on 'ReplicatedStorage.Models:WaitForChild("DemonMildzz")'

1

Silents his post makes no sense, if this is called by an OnServerEvent it means it could never possibly be running at game start. So a few seconds after you have joined. Everything is already loaded in ReplicatedStorage.

1 answer

✓ Accepted answer

I think you might be using the wrong names. Make sure that whatever data.Name is (according your comments something like DemonMildzz) is actually present inside of game.ReplicatedStorage.Models. If there's no instance with that exact name :FindFirstChild() will return nil. :WaitForChild() won't help either because it's going to infinitely wait until that child is added.

You forgot to add the player argument to your function, that is always the first argument passed to OnServerEvent (done automatically by Roblox). So I think you are trying to find an item in ReplicatedStorage with the player their name.

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