' CFrame is not a valid member of Script "Workspace.Dolls.Script" ' error keeps happening even though the scripts parent is a part

Hello! So ive been making a game but whenever i playtested it would always lag because of this error

 CFrame is not a valid member of Script "Workspace.Dolls.Script"

Dolls is a folder for where i keep my parts, but the script keeps saying that script.Parent is the script itself, I checked multiple times.

Heres the script:

local part = script.Parent
local collected = false
local Players = game:GetService("Players")

game:GetService("RunService").Heartbeat:Connect(function(dt)
	if part and part.Parent then
		part.CFrame = part.CFrame * CFrame.Angles(0, math.rad(180 * dt), 0)
	end
end)

part.Touched:Connect(function(hit)
	if collected then return end

	local character = hit.Parent
	local humanoid = character:FindFirstChildWhichIsA("Humanoid")
	local player = Players:GetPlayerFromCharacter(character)

	collected = true

	for _, plr in ipairs(Players:GetPlayers()) do
		local leaderstats = plr:FindFirstChild("leaderstats")
		if leaderstats then
			local wegasValue = leaderstats:FindFirstChild("Wegas") or leaderstats:FindFirstChild("wegas")
			if wegasValue and (wegasValue:IsA("IntValue") or wegasValue:IsA("NumberValue")) then
				wegasValue.Value += 1
			end
		end
	end

	local sound = part:FindFirstChild("Collect")
	if sound and sound:IsA("Sound") then
		sound:Play()
	end

	part.Anchored = true
	part.CanCollide = false
	part.Transparency = 1

	game:GetService("SoundService").SpawnedWega:Play()
	character.HumanoidRootPart.Anchored = true
	local wega = game:GetService("ServerStorage").Characters.Wega:Clone()
	wega.Parent = workspace.Chars
	task.wait(1.5)
	game:GetService("SoundService").SpawnedWega:Destroy()
	game:GetService("SoundService").Theme:Play()
	game:GetService("ServerStorage").Map:Clone().Parent = workspace
	local wegastart = game:GetService("ServerStorage").WegaScript
	wegastart.Parent = wega
	game:GetService("ServerStorage").Dolls:Clone().Parent = workspace
	wega.Normal:Play()
	task.wait(0.5)
	character.HumanoidRootPart.Anchored = false
	for i = 1, 12 do
		if part and part.Parent then
			part.CFrame = part.CFrame * CFrame.new(0, 0.7, 0)
		end
		task.wait(0.03)
	end

	if part and part.Parent then
		part:Destroy()
	end
end)

This is the hierarchy:
Screenshot 2025-11-25 145717

can you show me on what line this error occurs on please?

2 Likes

I see whats happening here…
You’re trying to access a CFrame within a part within a script

If you want to retrieve the CFrame of a part, you should do so like this:

part.CFrame

theres an extra script in the Dolls folder you have to destroy

1 Like

but he is literally doing that in his script?

the CFrame multiplication part is fine, but it still returns a CFrame, not a part, so the error is correct, since you can’t use CFrames for the .Parent property

They should use collection service anyways.

Not that this is the fix for you, but I do see that you are not checking if player is valid. You use GetPlayerFromCharacter, but then you need to check if that is == nil. Because if you touch something that is not part of a character, that player value will be nil.

at line 8

   part.CFrame = part.CFrame * CFrame.Angles(0, math.rad(spinSpeed * dt), 0)

i checked that script and yeah, that was the problem. i used the command bar to add scripts to all of the dolls, and i forgot to add a IsA() for a base part, thank you!

1 Like

hey, I dont know if you are making an advanced project or not, but maybe you should look up Collection Service in Roblox Docs. Way better having 1 script vs 50 scripts for 1 thing

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