I’m making a subway train for a game and want sliding doors that open when the player gets near them. So I made some and they worked for the outside doors, but the inside door to the drive cab is not opening on the client side. It works on the server but the tweeting doesn’t happen for any of the clients.
Hello! So firstly, we should not see any tweens on the server side, those should be handled entirely by the client (ideally).
You don’t have to move the door on the server, just make it non collideable. Also, would you be able to upload your script as a text version instead of a screenshot? It would help me provide a solution more computationally instead of just talking
Also, here is a script taken directly out of my game for a door.
local door = script.Parent
local sensor = door.ScanBox
local doorCoolDown = 8
local countDown = 0
--when sensor touched, open door for 10 seconds or something
sensor.Touched:Connect(function()
if tick() - countDown > doorCoolDown then
countDown = tick()
print("open door")
animateMachine:FireAllClients(door)
door.Outline.CanCollide = false
door.Brace.CanCollide = false
task.wait(doorCoolDown)
door.Outline.CanCollide = true
door.Brace.CanCollide = true
end
end)
----- Misc Varibles -----
local TweenService = game:GetService("TweenService")
local OpenTime = 1.5
local Info = TweenInfo.new(OpenTime, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut,0,false)
local Timer = script.Parent.Parent.Timer
local Sensor = script.Parent
local safty = script.Parent.Parent.CanOpen
----- Door Varibles -----
local Door = script.Parent.Parent.Door
local Pos = Door.Position
local Open = TweenService:Create(Door, Info, {Position = Vector3.new(Pos.X - 4.3, Pos.Y, Pos.Z)})
local Close = TweenService:Create(Door, Info, {Position = Vector3.new(Pos.X, Pos.Y, Pos.Z)})
----- Functions -----
local function CheckForHuman(hit)
if hit.Parent.Parent:FindFirstChild("Humanoid") then
return true
end
if hit.Parent:FindFirstChild("Humanoid") then
return true
end
end
----- Logic -----
Sensor.Touched:Connect(function(HIT)
if CheckForHuman(HIT) == true and safty.Value == true then
Sensor.CanTouch = false
Open:Play()
wait(OpenTime)
Sensor.CanTouch = true
Timer.Value = 2
end
end)
Timer.Changed:Connect(function()
if Timer.Value == 0 then
Close:Play()
end
end)