0% found this document useful (0 votes)
1K views2 pages

Touch Football Teleport To Ball Script

The document outlines a script for creating a graphical user interface (GUI) in Roblox that allows players to teleport a soccer ball. It includes the setup of a frame, button, and text label, along with properties for appearance and layout. The script also defines a function that teleports the ball in front of the player's character when the button is clicked, with error handling for missing components.

Uploaded by

ml5856082
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views2 pages

Touch Football Teleport To Ball Script

The document outlines a script for creating a graphical user interface (GUI) in Roblox that allows players to teleport a soccer ball. It includes the setup of a frame, button, and text label, along with properties for appearance and layout. The script also defines a function that teleports the ball in front of the player's character when the button is clicked, with error handling for missing components.

Uploaded by

ml5856082
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

-- Create the GUI

local ScreenGui = Instance.new("ScreenGui")


local Frame = Instance.new("Frame")
local Button = Instance.new("TextButton")
local TextLabel = Instance.new("TextLabel") -- Create TextLabel

-- Properties
ScreenGui.Name = "TeleportBallGui"
ScreenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")

Frame.Name = "Frame"
Frame.Parent = ScreenGui
Frame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
Frame.Position = UDim2.new(0.5, -100, 0.5, -50)
Frame.Size = UDim2.new(0, 200, 0, 100)
Frame.AnchorPoint = Vector2.new(0.5, 0.5)
Frame.Active = true
Frame.Draggable = true

Button.Name = "Button"
Button.Parent = Frame
Button.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
Button.Position = UDim2.new(0.15, 0, 0.35, 0) -- Positioned below the TextLabel
Button.Size = UDim2.new(0.7, 0, 0.55, 0) -- Adjusted size for better layout
Button.Font = Enum.Font.Cartoon
Button.Text = "Teleport Ball"
Button.TextColor3 = Color3.fromRGB(255, 255, 255)
Button.TextScaled = true

-- Create the TextLabel and position it at the top of the Frame


TextLabel.Name = "TextLabel"
TextLabel.Parent = Frame
TextLabel.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
TextLabel.BackgroundTransparency = 1 -- Make the background transparent
TextLabel.Position = UDim2.new(0, 0, 0, 0) -- Positioned at the top of the Frame
TextLabel.Size = UDim2.new(1, 0, 0.3, 0) -- Adjust size to fit at the top
TextLabel.Font = Enum.Font.Cartoon
TextLabel.Text = "Made with hate by Lennox"
TextLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
TextLabel.TextScaled = true

-- Script to handle button click


local function onButtonClick()
local player = game.Players.LocalPlayer
local character = player.Character
local field = game.Workspace:FindFirstChild("FootballField")

if field then
local ball = field:FindFirstChild("SoccerBall")

if character and ball then


local humRootPart = character:FindFirstChild("HumanoidRootPart")

if humRootPart then
-- Calculate the new position slightly in front of the player
local direction = humRootPart.CFrame.LookVector
local distance = 3 -- Move the ball 3 units in front of the player
local newPosition = humRootPart.Position + (direction * distance)
-- Teleport the ball using CFrame
ball.CFrame = CFrame.new(newPosition)
else
print("HumanoidRootPart not found") -- Output error message for
debugging
end
else
print("Character or Ball not found") -- Output error message for
debugging
end
else
print("FootballField not found") -- Output error message for debugging
end
end

Button.MouseButton1Click:Connect(onButtonClick)

You might also like