Hey Guys! I used this door script made by another person and was wondering why it was lagging on the roblox app. This doesn’t happen in studio just the roblox app.
local ts = game:GetService("TweenService")
local doors = script.Parent:GetChildren()
local function Tween(object, goal, easingStyle, Tweentime)
local tween = ts:Create(object, TweenInfo.new(Tweentime, easingStyle), goal)
return tween
end
for i, model in pairs(doors) do
if model:IsA("Model") then
for i, part in pairs(model:GetChildren()) do
if part ~= model.PrimaryPart and part:IsA("BasePart") then
local weld = Instance.new("WeldConstraint")
weld.Parent = model.PrimaryPart
weld.Part0 = model.PrimaryPart
weld.Part1 = part
part.Anchored = false
end
end
end
end
for i, model in pairs(doors) do
if model:IsA("Model") then
local open = false
local db = false
local prompt1 = Instance.new("ProximityPrompt")
prompt1.Parent = model.Handle1
prompt1.ActionText = "Open"
prompt1.MaxActivationDistance = 7
prompt1.Style = Enum.ProximityPromptStyle.Custom
local prompt2 = Instance.new("ProximityPrompt")
prompt2.Parent = model.Handle2
prompt2.ActionText = "Open"
prompt2.MaxActivationDistance = 7
prompt2.Style = Enum.ProximityPromptStyle.Custom
prompt1.Triggered:Connect(function(player)
if db == false then
db = true
if open then
open = false
prompt1.ActionText = "Open"
prompt2.ActionText = "Open"
local tween = Tween(model.PrimaryPart, {CFrame = model.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(100), 0)}, Enum.EasingStyle.Sine, 1)
tween:Play()
else
open = true
prompt1.ActionText = "Close"
prompt2.ActionText = "Close"
local tween = Tween(model.PrimaryPart, {CFrame = model.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(-100), 0)}, Enum.EasingStyle.Sine, 1)
tween:Play()
end
task.wait(1)
db = false
end
end)
prompt2.Triggered:Connect(function(player)
if db == false then
db = true
if open then
open = false
prompt1.ActionText = "Open"
prompt2.ActionText = "Open"
local tween = Tween(model.PrimaryPart, {CFrame = model.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(100), 0)}, Enum.EasingStyle.Sine, 1)
tween:Play()
else
open = true
prompt1.ActionText = "Close"
prompt2.ActionText = "Close"
local tween = Tween(model.PrimaryPart, {CFrame = model.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(-100), 0)}, Enum.EasingStyle.Sine, 1)
tween:Play()
end
task.wait(1)
db = false
end
end)
end
end