Position cannot be assigned to error

Hey! I’m trying to set the position of a cloned part, however, I get this error.

local EasterEggsFolder = RS:WaitForChild("EasterEggs")
local LocationsEggs = workspace:WaitForChild("EasterEggsLocations")

local currentEggLocation

local function getRandomEggLocation()
	for i, v in pairs(LocationsEggs:GetChildren()) do
		currentEggLocation = v.Name
	end
end

local collectedEggs = player:WaitForChild("EasterFolder"):WaitForChild("EggsCollected")


EggsEvent.OnClientEvent:Connect(function()
	getRandomEggLocation()
	local eggToClone = EasterEggsFolder:FindFirstChild("Egg"..collectedEggs.Value + 1):Clone()
	eggToClone.Parent = workspace
	eggToClone.CFrame.Position = LocationsEggs[currentEggLocation].CFrame.Position
end)

maybe the script couldn’t find the currentEggLocation. use findfirstchild to check if object exists.

1 Like

It seems to find it, just tried it with :FindFirstChild() and it still returns the same error.

you should Use Vector3 for it.because i also get the same error while assigning the position to a position variable.

eggToClone.CFrame.Position = Vector3.new(LocationsEggs[currentEggLocation].CFrame.Position)

if it wont worked try this one:

local CurrentEgg = LocationsEggs:FindFirstChild(currentEggLocation)
eggToClone.CFrame.Position = Vector3.newCurrentEgg.Position.X.,CurrentEgg.Position.Y,CurrentEgg.Position.Z)
1 Like
eggToClone.CFrame = CFrame.new(LocationsEggs[currentEggLocation].CFrame.Position)
1 Like

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