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

CFrame.Y cannot be assigned to?

So basically, I'm creating this double-jump script in which a part will appear on the bottom of the player's foot giving them a brief period to jump on that part.

Script:

--ServerScript inside of a part
script.Parent.Touched:Connect(function(hit)
	if hit.Parent:WaitForChild('Humanoid') then
		local touching = script.Parent:GetTouchingParts()
		local part = Instance.new("Part",workspace)
		part.Size = Vector3.new(1,1,1)
		part.Name = "hi"
		part.Anchored = true
		part.CanCollide = true
		part.CFrame = hit.Parent:WaitForChild('HumanoidRootPart').CFrame
		part.CFrame.Y = hit.Parent:WaitForChild('Humanoid').HipHeight - 2
		wait(.1)
		part:remove()
		for _, p in next, touching do
			print(p.Name.." is touching "..script.Parent.Name)
		end
	end
end)

The thing is, on line 11, it says: Y cannot be assigned to

Any help please?

1 answer

✓ Accepted answer

It means properties like CFrame.Y are read-only. You have to change part.CFrame instead (though of course you can still only change the Y value):

part.CFrame = CFrame.new(part.CFrame.X, hit.Parent:WaitForChild('Humanoid').HipHeight - 2, part.CFrame.Z)

1 comment

0

Ty!

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