I can’t identify why my door tween is playing right when the game starts. I assume it has to do with my server code but I’m really not too sure.
Server
Events.EnterDoor.OnServerEvent:Connect(function(Player, Door)
local Configuration = Door.Configuration
local CanOpen = Configuration.CanOpen
local DoorTweenInfo = TweenInfo.new(0.6, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
local DoorTween = TweenService:Create(Door.Root, DoorTweenInfo, {CFrame = Door.Root.CFrame * CFrame.Angles(0, math.rad(120), 0)})
if CanOpen.Value == true then
CanOpen.Value = false
DoorTween:Play()
DoorTween.Completed:Wait()
wait(5)
CanOpen.Value = true
end
end)
Client
local Doors = workspace:WaitForChild("Doors")
local CanOpenDoor = true
RunService.RenderStepped:Connect(function()
for _, Door in pairs(Doors:GetChildren()) do
if Player:DistanceFromCharacter(Door.EnterRadius.Position) >= 5 and CanOpenDoor == true then
Events.EnterDoor:FireServer(Door.Door)
CanOpenDoor = false
end
end
end)