MeshPart doesn't rotate via CFrame Angles

So i got a proper locker model and that also means i had to adapt the code and the locker to work together (past me should have never touched coding)

now everything runs perfectly, except for one thing, the meshpart doesn’t actually rotate and no errors are given?

-- // TWEEN PARAMETERS
local info = TweenInfo.new(
	.2,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.Out
)
local angleOffset = -180

function onPromptTriggered(proximityPrompt, player)
	---------------LOCKER RNG---------------
	if proximityPrompt.Parent.Parent.Name == "Door" then
		
		local door = proximityPrompt.Parent.Parent
		local hinge = door.Parent.Locker.Hinge
		local OpenAnimation = TS:Create(door, info, {CFrame = hinge.CFrame * CFrame.Angles(0, angleOffset, 0)})
		
		OpenAnimation:Play()
		door.CanCollide = false
		door.OpenSound:Play()
-- // There's nothing relevant to the tween below here so i'm leaving it out, yes i do call the function

this worked fine when i was rotating a Part, but now it just doesn’t : (

can you just paste the whole script here?

yeah sure

local PPS = game:GetService("ProximityPromptService")
local SS = game:GetService("ServerStorage")
local TS = game:GetService("TweenService")

---------------LOOT VARIABLES AND CHANCES---------------
local Weapons = SS:WaitForChild("Weapons")

local LootChances = {
	[Weapons:WaitForChild("Shovel")] = 50,
	[Weapons:WaitForChild("Glock18")] = 50
}

-- // TWEEN PARAMETERS
local info = TweenInfo.new(
	.2,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.Out
)
local angleOffset = -180

function onPromptTriggered(proximityPrompt, player)
	---------------LOCKER RNG---------------
	if proximityPrompt.Parent.Parent.Name == "Door" then
		
		local door = proximityPrompt.Parent.Parent
		local hinge = door.Parent.Locker.Hinge
		local OpenAnimation = TS:Create(door, info, {CFrame = hinge.CFrame * CFrame.Angles(0, angleOffset, 0)})
		
		OpenAnimation:Play()
		door.CanCollide = false
		door.OpenSound:Play()
		
		local function pickRandom()
			local totalChance = 0
			for _,chance in pairs(LootChances) do
				totalChance += chance
			end
			local rng = math.random(1,totalChance)

			for item,chance in pairs(LootChances) do
				rng -= chance
				if rng <= 0 then
					return item
				end
			end
		end
		
		proximityPrompt.Enabled = false
		local loot = pickRandom():Clone()
		loot.Parent = door.Parent.LootPart
		loot:SetPrimaryPartCFrame(door.Parent.LootPart.CFrame)
		
		---------------TOOL---------------
	elseif proximityPrompt.Parent.Parent:IsA("Tool") then
		local LootPart = proximityPrompt.Parent.Parent.Parent
		
		local Tool = LootPart:FindFirstChildOfClass("Tool")
		local ToolInv = Tool:Clone()
		
		LootPart.PickSound:Play()
		Tool:Destroy()
		ToolInv.Parent = player.Backpack
		ToolInv:FindFirstChild("Unhandle").Name = "Handle"
		ToolInv.Handle.Anchored = false
		ToolInv.Handle.PickUp.Enabled = false -- PickUp = Tool's ProximityPrompt
	end
end

PPS.PromptTriggered:Connect(onPromptTriggered)

the parameters of CFrame.Angles are supposed to be in radians, you are providing degrees;

in the CFrame.Angles constructor, instead of directly inputting your angle as degrees, first convert them into radians via the math.rad function:

CFrame.Angles(0, math.rad(angleOffset), 0)

(inputting 180 degrees may not turn the door in the correct direction you want, if so, you could use an angle smaller than 180 such as 179.99)

i tried this, didn’t work

for some damn reason it didn’t work because the meshpart was unanchored…

i have no idea what anchored changes but it works now
stupidest fix ever, i hate game development

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