I have this script that detect if a player is nearby by using a radius, I want a gui to show up when the player is inside the radius with tweening, and when the player leave the inside of the radius the gui will tween back to its hiding place. The problem is that when the player leave before the tween stop or while the tween is playing, the tween will stay there until the player come back to the radius and leave. How do I fix this?
UserInputService.InputBegan:Connect(function(input) RunService.Heartbeat:Connect(function() if (Center - Player.Character.HumanoidRootPart.Position).Magnitude <= Radius and not PlayerIn and not texton then texton = true PlayerIn = true print(Player.Name.." is in the circle!") text:TweenPosition(UDim2.new(0,462,0,500), 'Out', 'Quad', 0.2) end end) end) RunService.Heartbeat:Connect(function() if (Center - Player.Character.HumanoidRootPart.Position).Magnitude > Radius and PlayerIn and texton then PlayerIn = false texton = false text:TweenPosition(UDim2.new(0,462,0,700), 'Out', 'Quad', 0.2) print(Player.Name.." is outside the circle!") end end)