Unable to assign property CFrame. CoordinateFrame expected, got nil

Error comes from 2 scripts:

Script1

		local placedTower = spawnTowerFunction:InvokeServer(TowerToSpawn.Name, FernC)

Script2

		newTower.HumanoidRootPart.CFrame = cframe

I HAVE TRIED EVERYTHING I CAN TO FIX IT AND IT IS EXTREMELY ANNOYING!

cframe is nil, but you aren’t really showing any of your script to speak of so I couldn’t tell you why. Just make cframe not nil and it will work.

Also the error isn’t coming from two scripts, you’re probably seeing the stack trace. That’s just the path of functions that were called to get to where the error is.

2 Likes

Ah, I see. I do believe this works for every tower apart from one which is a cliff tower.

I do believe that cframe is not nil. Perhaps I could show more of it so.

Here is ALL of the code then:

function tower.Spawn(player, name, cframe, previous)
	local allowedToSpawn = tower.CheckSpawn(player, name)

	if allowedToSpawn then	
		local newTower
		local oldMode = nil
		if previous then
			oldMode = previous.Config.TargetMode.Value
			previous:Destroy()
			newTower = ReplicatedStorage.Towers.Upgrades[name]:Clone()      
			player.placedTowers.Value -= 1
		else
			newTower = ReplicatedStorage.Towers[name]:Clone()
			player.placedTowers.Value += 1
		end
		print(player.placedTowers.Value)
		local ownerValue = Instance.new("StringValue")
		ownerValue.Name = "Owner"
		ownerValue.Value = player.Name
		ownerValue.Parent = newTower.Config

		local targetMode = Instance.new("StringValue")
		targetMode.Name = "TargetMode"
		targetMode.Value = oldMode or "First"
		targetMode.Parent = newTower.Config

		newTower.HumanoidRootPart.CFrame = cframe
		newTower.Parent = workspace.Towers
		newTower.HumanoidRootPart:SetNetworkOwner(nil)

		for i, object in ipairs(newTower:GetDescendants()) do
			if object:IsA("BasePart") then	
				PhysicsService:SetPartCollisionGroup(object, "Tower")
				object.CanCollide = false
				object.CanTouch = false
				object.CanQuery = false
				if object.Name == "HumanoidRootPart" then
					object.Anchored = true
				else
					object.Anchored = false
				end
				object.Massless = true
			end
		end
		
		local isAtk = Instance.new("BoolValue",newTower.Config)
		isAtk.Name = "IsAttacking"
		isAtk.Value = true
		isAtk.Changed:Connect(function(change)
			if change == false then
				local effect = game.ReplicatedFirst.StunFX.Star:Clone()
				if newTower:FindFirstChild("Head") then
					effect.Parent = newTower.Head
				else
					effect.Parent = newTower.HumanoidRootPart
				end
				task.wait(5)
				effect:Destroy()
				isAtk.Value = true
			end
		end)
		
		player.Credits.Value -= newTower.Config.Price.Value

		coroutine.wrap(tower.Attack)(newTower, player)

		return newTower
	else
		warn("Requested Tower Does Not Exist:", name)
		return false
	end
end

Where are you calling this function?

1 Like

I managed to fix it THANK GOD, I appreciate the help. At the start of the script was a local that was like

local TweenCFrame

After tinkering I managed to fix it. I’ll let you know if there are any more bugs I encounter.

1 Like

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