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 : (
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)