I'm trying to copy and paste a part into the player, but when I do it gives me an error "Trying to set locked parent" without any more info, can someone help?

local function MakeMarble(Plr, Marble)
	local p = Marble.Marble
	p.Parent = game.Workspace[Plr.Name]
	p.Position = Vector3.new(math.random(-1000,1000), 70, math.random(-1000,1000))
	p.Anchored = false
	local b = Instance.new("BodyVelocity")
	b.velocity = Vector3.new(0,-1000,0)
	b.maxForce = Vector3.new(50000,50000,50000)
	b.Parent = p
	local Clone = game.ServerStorage.IntoMarble:clone()
	Clone.Parent = Plr.Character.Marble
	Clone.Disabled = false
	Plr.leaderstats.Size.Value = 1
end
game.ReplicatedStorage.MarbleMaker.OnServerEvent:Connect(MakeMarble)

Plr is the player in game.Players, Marble is a group inside the workspace and Marble.Marble is a part named "Marble" inside that group.

2 comments

0

Line of error?

0

If the error doesn't include line number, you can try stepping through your code with the debugger to find it manually.