Hello. im making a wardrobe locker system like in the game ‘Doors’ and its giving me serious stress because it just won’t work for some reason.
I can make a copy of my game so u could fix my scripts if u would like
it wont run the code after this line
‘If enter_locker then’
and if it won’t run it, it won’t be able to work and i can’t seem to make it run the code for some reason
Sorry for bad explanation
Here are the scripts:
WardrobeFunctions: in ServerScriptService
-- SERVICES
local TS = game:GetService("TweenService")
local function TweenModel(model,endcf,t)
spawn(function()
local cframe_value = Instance.new("CFrameValue")
cframe_value.Value = model.Primary.CFrame
cframe_value:GetPropertyChangedSignal("Value"):Connect(function()
model:SetPrimaryPartCFrame(cframe_value.Value)
end)
TS:Create(cframe_value,TweenInfo.new(t),{Value = endcf}):Play()
game.Debris:AddItem(cframe_value,t)
end)
end
local function GetTouchingParts(part)
local connection = part.Touched:Connect(function() end)
local results = part:GetTouchingParts()
connection:Disconnect()
return results
end
game.ReplicatedStorage.Remotes:WaitForChild("Wardrobe").Enter.OnServerEvent:Connect(function(player, wardrobe)
if wardrobe.Occupant.Value ~= nil or wardrobe.Db.Value == true then return end
local enter_locker = false
local character = player.Character
local hrp = character:FindFirstChild("HumanoidRootPart")
local humanoid = character:FindFirstChild("Humanoid")
if hrp then
for i,lockers in pairs(GetTouchingParts(hrp)) do
if lockers.Name == "Hitbox" and lockers.Parent.Name == "Wardrobe" then
enter_locker = true
end
end
-- Occupant
end
if enter_locker then
TweenModel(wardrobe.Wardrobe.Door1,wardrobe.Wardrobe.Door1.Primary.CFrame*CFrame.Angles(0,30,0),0.5)
TweenModel(wardrobe.Wardrobe.Door2,wardrobe.Wardrobe.Door2.Primary.CFrame*CFrame.Angles(0,-30,0),0.5)
wardrobe.Db.Value = true
wardrobe.Occupant.Value = player
hrp.Anchored = true
humanoid.PlatformStand = true
spawn(function()
wait(0.25)
TS:Create(hrp,TweenInfo.new(0.5),{CFrame = wardrobe.Center.CFrame}):Play()
wait(0.5)
humanoid.PlatformStand = false
TweenModel(wardrobe.Wardrobe.Door1,wardrobe.Wardrobe.Door1.Primary.CFrame*CFrame.Angles(0,-30,0),0.5)
TweenModel(wardrobe.Wardrobe.Door2,wardrobe.Wardrobe.Door2.Primary.CFrame*CFrame.Angles(0,30,0),0.5)
wait(0.7)
wardrobe.Db.Value = false
end)
end
end)
game.ReplicatedStorage.Remotes:WaitForChild("Wardrobe").Exit.OnServerEvent:Connect(function(player, wardrobe)
if wardrobe.Occupant.Value == nil or wardrobe.Db.Value == true then return end
local character = player.Character
local hrp = character:FindFirstChild("HumanoidRootPart")
if wardrobe.Occupant.Value == player then
TweenModel(wardrobe.Wardrobe.Door1,wardrobe.Wardrobe.Door1.Primary.CFrame*CFrame.Angles(0,30,0),0.5)
TweenModel(wardrobe.Wardrobe.Door2,wardrobe.Wardrobe.Door2.Primary.CFrame*CFrame.Angles(0,-30,0),0.5)
wardrobe.Db.Value = true
wardrobe.Occupant.Value = player
--hrp.Anchored = true
spawn(function()
wait(0.25)
TS:Create(hrp,TweenInfo.new(0.5),{CFrame = wardrobe.Exit.CFrame}):Play()
wait(0.5)
hrp.Anchored = false
wardrobe.Occupant.Value = nil
TweenModel(wardrobe.Wardrobe.Door1,wardrobe.Wardrobe.Door1.Primary.CFrame*CFrame.Angles(0,-30,0),0.5)
TweenModel(wardrobe.Wardrobe.Door2,wardrobe.Wardrobe.Door2.Primary.CFrame*CFrame.Angles(0,30,0),0.5)
wait(0.7)
wardrobe.Db.Value = false
end)
end
end)
Interactables: in StarterCharacterScripts
local TS = game:GetService("TweenService")
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character
local hrp = character:WaitForChild("HumanoidRootPart")
local humanoid = character:WaitForChild("Humanoid")
local function GetTouchingParts(part)
local connection = part.Touched:Connect(function() end)
local results = part:GetTouchingParts()
connection:Disconnect()
return results
end
-- WARDROBE
UIS.InputBegan:Connect(function(input,gpe)
if gpe then return end
if input.KeyCode == Enum.KeyCode.E then
local enter_locker = false
for i,lockers in pairs(GetTouchingParts(hrp)) do
if lockers.Name == "Hitbox" and lockers.Parent.Name == "Wardrobe" and lockers.Parent:FindFirstChild("Db") and lockers.Parent.Db.Value == false then
game.ReplicatedStorage.Remotes:FindFirstChild("Wardrobe").Enter:FireServer(lockers.Parent)
print("enter")
local enter_locker = true
end
end
if not enter_locker then
for i,lockers in pairs(workspace.Interactables:GetChildren()) do
if lockers.Name == "Wardrobe" and lockers.Occupant.Value == player and lockers:FindFirstChild("Db") and lockers.Db.Value == false then
game.ReplicatedStorage.Remotes:FindFirstChild("Wardrobe").Exit:FireServer(lockers)
print("exit")
end
end
end
end
end)
Help is appreciated