What do you want to achieve? fixing my script and fixing the functionality.
What is the issue? I have a GUI script that opens when the player is within the vicinity of a part, and it should close when the player walks away. Along with this, there is a close button to close out the frame.
The close button does not work always, and only consistently works when outside the range.
- What solutions have you tried so far? I have seen many scripts with the magnitude, but none with a close button on it too. I believe the problem is that the game still detects the player is in the range, so it can’t fully close out.
The above video should showcase that the GUI opens and closes, but the close button does not work.
Here is my script.
while wait() do if (touch.Position - character:WaitForChild("HumanoidRootPart").Position).Magnitude < 10 and isBought.Value == false then script.Parent:TweenPosition(UDim2.new(0.3,0,0.213,0), "In","Bounce",0.5) else wait() script.Parent:TweenPosition(UDim2.new(0.3,0,1.5,0), "Out","Bounce",0.5) end script.Parent.Frame.CloseButton.MouseButton1Click:Connect(function() if canClick then canClick = false script.Parent:TweenPosition(UDim2.new(0.3,0,1.5,0), "Out","Bounce",0.5) wait(1) canClick = true end end) end
If you need me to clarify anything more, please let me know.