#door system
1 messages · Page 1 of 1 (latest)
Send the script trough """script"""
Or sum like that
So people don't have to download it
It raises the chance of help
all scripters are on pc
I am
you on what
I jist dont have acces to my pc rn
its downloading and opening it
I need to select it
select what
Yh
im tryna solve the problem of these weird "offsets"
Try screenshotting it
k
I dont wanna tho
is really long
no
Are you using tweens?
yes
here:
Youre applying the same animation for both doors (it looks loke ot) but you have to make some values negative or positive
nope
its preset parts
half of script: local TweenService = game:GetService("TweenService")
local POP_TIME = 1.5
local SLIDE_TIME = 2.5
local WAIT_BEFORE_DOORS = 1
local TWEEN_DELAY = 1.5
local HOLD_OPEN_TIME = 10
local SOUND_DELAY = 2
local car = script.Parent
local model = car.Parent
local leftSide = model.Left
local openValue = model.Open
local soundDO = car.DO
local soundDC = car.DC
local seat = car.Bogie.Seats.MainSeat
local tweens = {}
local operating = false
local function cancelTweens()
for _, t in tweens do t:Cancel() end
tweens = {}
end
local function operateDoors()
if operating then return end
operating = true
-- Wait for throttle to be zero before anchoring
repeat task.wait(0.1) until seat.Throttle == 0
-- Anchor the train
for _, part in car:GetDescendants() do
if part:IsA("BasePart") then
part.Anchored = true
end
end
So the issue is that one of the doors animate into the wrong direction right?
-- Wait for physics to calm down
task.wait(WAIT_BEFORE_DOORS)
soundDO:Play()
local sideName = leftSide.Value and "L" or "R"
local sideGroup = car:WaitForChild(sideName)
local popModel = sideGroup:WaitForChild("Pop")
local openModel = sideGroup:WaitForChild("Open")
local doorData = {}
-- Capture the CURRENT state of the doors and the targets (fresh every cycle)
for _, panel in sideGroup:GetChildren() do
if panel:IsA("Model") and (panel.Name == "L" or panel.Name == "R") then
local popTarget = popModel:FindFirstChild(panel.Name)
local openTarget = openModel:FindFirstChild(panel.Name)
if popTarget and openTarget then
doorData[panel] = {
startCF = panel:GetPivot(), -- current door pos (fresh!)
popCF = popTarget:GetPivot(), -- current pop target (fresh!)
openCF = openTarget:GetPivot() -- current open target (fresh!)
}
print("[DOOR] "..panel.Name.." startCF:", panel:GetPivot())
print("[DOOR] "..panel.Name.." popCF:", popTarget:GetPivot())
print("[DOOR] "..panel.Name.." openCF:", openTarget:GetPivot())
end
end
end
-- Pop tween
local cfValues = {}
for panel, data in doorData do
local cf = Instance.new("CFrameValue")
cf.Value = data.startCF -- Reset to fresh starting point!
cf.Changed:Connect(function(v)
panel:PivotTo(v)
end)
cf.Parent = panel
cfValues[panel] = cf
.
I cant
istg this aint rocket science
My phone not support
I got an old phone
and how it going to ruin it
Idk imploding
then why the hell is it offseting on preset models
I mean one of the doors is sliding the wrong way right?
PRESET MODELS, every door cycle, it resets all to nil, and then refreshes to open which is target and start which is itself
nah, all of them
so one is going inward to the train (1 stud) and outward (1 stud) and if i just add 1 stud or subtract 1 stud, thats overly specfic, because thats just fixing one problem
I dont get the issue like whats breaking?
its offseting
Oh yh
holy ai scripting
** You are now Level 11! **
Might be bc one of the parts allignorientation is in a different direction
Idk man
So
no, just look at this part:
doesnt mean you solely script with ai 💔
bro
What I'm seeing is that its gun add the pos to localspace which can be affected by localorientation
everyone has atleast used ai once
It dont matter if u use ai or not
i read every part of the code
We just need to fix it
AND its using preset models
so its using: local popTarget = popModel:FindFirstChild(panel.Name)
local openTarget = openModel:FindFirstChild(panel.Name)
if popTarget and openTarget then
doorData[panel] = {
startCF = panel:GetPivot(), -- current door pos (fresh!)
popCF = popTarget:GetPivot(), -- current pop target (fresh!)
openCF = openTarget:GetPivot() -- current open target (fresh!)
}
print("[DOOR] "..panel.Name.." startCF:", panel:GetPivot())
print("[DOOR] "..panel.Name.." popCF:", popTarget:GetPivot())
print("[DOOR] "..panel.Name.." openCF:", openTarget:GetPivot())
end
yet it happens to be offset???!
this one is the one who gets the cframe or pivot: startCF = panel:GetPivot()
popCF = popTarget:GetPivot()
openCF = openTarget:GetPivot(), but wth
Honestly pretty weird code you could prpb improve this by just running 1 loop that opens and closes it
Do the same tweem but add a vector3 to local position
Of the door
If ya wanna tilt or rot it do it also with local rotation
then
If u want u can also ask ai to implement it
and just wait
it forgets every last pivot
and refreshes
and these offsets happen outta nowhere
even crazier it uses preset models that dont move an inch
who the hell is trolling
U can use toobjectspace
Basically do: parentofpart:toobjectspace(part:getpivot())
Idk man u got weird script going on
Idk why its messing it up ngl
So this is just a guess
Then apply it like this during the tween:
cf.Changed:Connect(function(v)
panel:PivotTo(car:GetPivot() * v)
end)
oh
Yh 🙏😭
Its either that or just change a positive to a negative
Should be the Z in your case (object space)