Caulitcal
(Caulitcal)
#1
robloxapp-20231022-1939397.wmv (1.1 MB)
Script:
local tweenservice = game:GetService("TweenService")
local model = script.Parent
local rightglass = model.rightglasser.rightglass
local leftglass = model.leftglasser.leftglass
local prompt = model.top.Attachment.ProximityPrompt
local tweeninfo = TweenInfo.new(1)
local leftgoalopen = {}
local leftgoalclose = {}
local leftgoalopen = CFrame.new(leftglass.Position + Vector3.new(leftglass.Size.X, 0, 0 ))
local leftgoalclose = leftglass.CFrame
local lefttweenopen = tweenservice:Create(leftglass,tweeninfo, {CFrame = leftgoalopen})
local lefttweenclose = tweenservice:Create(leftglass, tweeninfo, {CFrame = leftgoalclose})
local rightgoalopen = {}
local rightgoalclose = {}
local rightgoalopen = CFrame.new(rightglass.Position + Vector3.new(-rightglass.Size.X, 0, 0))
local rightgoalclose = rightglass.CFrame
local righttweenopen = tweenservice:Create(rightglass,tweeninfo, {CFrame = rightgoalopen})
local righttweenclose = tweenservice:Create(rightglass, tweeninfo, {CFrame = rightgoalclose})
prompt.Triggered:Connect(function()
if leftglass.Anchored and rightglass.Anchored then
leftglass.Anchored = false
rightglass.Anchored = false
lefttweenopen:Play()
righttweenopen:Play()
wait(tweeninfo.Time)
leftglass.Anchored = true
rightglass.Anchored = true
prompt.ActionText = "Close"
else
lefttweenclose:Play()
righttweenclose:Play()
wait(tweeninfo.Time)
leftglass.Anchored = true
rightglass.Anchored = true
prompt.ActionText = "Open"
end
end)
Can someone help me fix this issue?
I think if you just always keep leftglass.Anchored
and rightglass.Anchored
to true
, it should work correctly
local tweenservice = game:GetService("TweenService")
local model = script.Parent
local rightglass = model.rightglasser.rightglass
local leftglass = model.leftglasser.leftglass
local prompt = model.top.Attachment.ProximityPrompt
local tweeninfo = TweenInfo.new(1)
local leftgoalopen = {}
local leftgoalclose = {}
local leftgoalopen = CFrame.new(leftglass.Position + Vector3.new(leftglass.Size.X, 0, 0 ))
local leftgoalclose = leftglass.CFrame
local lefttweenopen = tweenservice:Create(leftglass,tweeninfo, {CFrame = leftgoalopen})
local lefttweenclose = tweenservice:Create(leftglass, tweeninfo, {CFrame = leftgoalclose})
local rightgoalopen = {}
local rightgoalclose = {}
local rightgoalopen = CFrame.new(rightglass.Position + Vector3.new(-rightglass.Size.X, 0, 0))
local rightgoalclose = rightglass.CFrame
local righttweenopen = tweenservice:Create(rightglass,tweeninfo, {CFrame = rightgoalopen})
local righttweenclose = tweenservice:Create(rightglass, tweeninfo, {CFrame = rightgoalclose})
leftglass.Anchored = true
rightglass.Anchored = true
prompt.Triggered:Connect(function()
if leftglass.Anchored and rightglass.Anchored then
lefttweenopen:Play()
righttweenopen:Play()
wait(tweeninfo.Time)
prompt.ActionText = "Close"
else
lefttweenclose:Play()
righttweenclose:Play()
wait(tweeninfo.Time)
prompt.ActionText = "Open"
end
end)
1 Like
Caulitcal
(Caulitcal)
#3
Tried your script, it opens smoothly but when I press E again to close it, it doesn’t close
Sorry I didn’t check the condition on your if statement, here is the revised version that handles opening and closing with a boolean:
local tweenservice = game:GetService("TweenService")
local model = script.Parent
local rightglass = model.rightglasser.rightglass
local leftglass = model.leftglasser.leftglass
local prompt = model.top.Attachment.ProximityPrompt
local tweeninfo = TweenInfo.new(1)
local leftgoalopen = {}
local leftgoalclose = {}
local leftgoalopen = CFrame.new(leftglass.Position + Vector3.new(leftglass.Size.X, 0, 0 ))
local leftgoalclose = leftglass.CFrame
local lefttweenopen = tweenservice:Create(leftglass,tweeninfo, {CFrame = leftgoalopen})
local lefttweenclose = tweenservice:Create(leftglass, tweeninfo, {CFrame = leftgoalclose})
local rightgoalopen = {}
local rightgoalclose = {}
local rightgoalopen = CFrame.new(rightglass.Position + Vector3.new(-rightglass.Size.X, 0, 0))
local rightgoalclose = rightglass.CFrame
local righttweenopen = tweenservice:Create(rightglass,tweeninfo, {CFrame = rightgoalopen})
local righttweenclose = tweenservice:Create(rightglass, tweeninfo, {CFrame = rightgoalclose})
leftglass.Anchored = true
rightglass.Anchored = true
local isOpen = false
prompt.Triggered:Connect(function()
if not isOpen then
lefttweenopen:Play()
righttweenopen:Play()
wait(tweeninfo.Time)
prompt.ActionText = "Close"
isOpen = true
else
lefttweenclose:Play()
righttweenclose:Play()
wait(tweeninfo.Time)
prompt.ActionText = "Open"
isOpen = false
end
end)
1 Like
Caulitcal
(Caulitcal)
#5
Thank you so much! It works now.
2 Likes
system
(system)
Closed
#6
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.