local UserInputService = game:GetService("UserInputService")
local Flying = false
local TimesSpacedBarPressed = 0
local Player = game.Players.LocalPlayer
UserInputService.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.Space then
TimesSpacedBarPressed = TimesSpacedBarPressed + 1
if Flying == false then
if TimesSpacedBarPressed >= 2 then
local BodyForce = Instance.new("BodyForce")
BodyForce.Parent = Player.Character:WaitForChild("HumanoidRootPart")
BodyForce.Force = Vector3.new(10,4000,10)
BodyForce.Name = "Force"
Flying = true
local Gui = Instance.new("ScreenGui")
Gui.Parent = Player.PlayerGui
Gui.Name = "FlyingGui"
local CopyFrom = script.Parent.CopyButton
local CancelFlying = Instance.new("TextButton")
CancelFlying.Text = "Stop flying"
CancelFlying.Parent = Gui
CancelFlying.Position = UDim2.new(0.8,0,0.5,0)
CancelFlying.Size = UDim2.new(0, CopyFrom.AbsoluteSize.X, 0, CopyFrom.AbsoluteSize.Y)
CancelFlying.Rotation = CopyFrom.AbsoluteRotation
CancelFlying.MouseButton1Click:Connect(function()
Flying = false
CancelFlying.Parent:Destroy()
if game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart"):FindFirstChild("Force") then
game.Players.LocalPlayer.Character.HumanoidRootPart.Force:Destroy()
end
TimesSpacedBarPressed = 0
end)
end
end
end
end)
what i did was made button and named it copy button which u will notice in line 23 so what you should do is create a button in screengui and name it CopyButton Like in the Image.
then the button we will create will take the size and absolute size from the copy button we made. If you would like to ask anything tell me
Edit: I was wrong you can use Activated if you would like to sorry for the confusion