Hi there, I have a gui part script that shows the gui when the part is touched. What I’m trying to achieve is to make it so that when it’s not touching the part, the gui disappears. I’ve tried using touchended however that didn’t seem to work.
local gui = script.Parent.Parent.Parent.GUI
local button = script.Parent
local part = workspace.Shop.Model.GUIPart
local shop = part.GUIPart
gui.Visible = true
gui.Position = UDim2.new(0.5,0,1.302,0)
button.MouseButton1Click:Connect(function()
workspace.clickeffect:Play()
if gui.Position == UDim2.new(0.5,0,1.302,0) then
gui:TweenPosition(
UDim2.new(0.5,0,0.5,0),
"Out",
"Sine",
.5,
false
)
else
gui:TweenPosition(
UDim2.new(0.5,0,1.302,0),
"Out",
"Sine",
.5,
false
)
end
end)
shop.Touched:Connect(function()
if gui.Position == UDim2.new(0.5,0,1.302,0) then
gui:TweenPosition(
UDim2.new(0.5,0,0.5,0),
"Out",
"Sine",
.5,
false
)
else
gui:TweenPosition(
UDim2.new(0.5,0,1.302,0),
"Out",
"Sine",
.5,
false
)
end
end)
local function TouchEnded(hit)
if (hit.Parent:findFirstChild("Humanoid") ~= nil) then
gui:TweenPosition(
UDim2.new(0.5,0,1.302,0),
"Out",
"Sine",
.5,
false
)
end
end