Last active
January 21, 2024 17:50
-
-
Save Fizzyhex/3c8f2e468b85c491ddd3f5f26b5f8fbc to your computer and use it in GitHub Desktop.
⚽ Team create football - A fun script for Roblox team create
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
@Fizzyhex, 2023 | |
Select the part you want to use as a ball and paste this into your command bar! | |
This script will then clone it and turn it into a ball. | |
For others to kick the ball around they'll need to run this script too. Have fun :> | |
---- | |
Extra: | |
- The ball will have archivable set to false, so it wont be kept around when the | |
place is saved. | |
- Try adding ramps! | |
--]] | |
local CollectionService = game:GetService("CollectionService") | |
local Selection = game:GetService("Selection") | |
local ball: BasePart = Selection:Get()[1]:Clone() | |
local camera = workspace.CurrentCamera | |
local velocity = Vector3.new() | |
assert(ball, "you need to select the ball before you run this script!") | |
assert(ball:IsA("BasePart"), "only parts are supported!") | |
local ballCollider = Instance.new("Part") | |
ballCollider.Transparency = 1 | |
ballCollider.Size = Vector3.zero | |
ballCollider.Name = "BallCollider" | |
ballCollider.Archivable = false | |
ballCollider.Locked = true | |
CollectionService:AddTag(ballCollider, "BallCollider") | |
ballCollider.Parent = workspace | |
ball.Name = "TeamCreateBall" | |
ball.Parent = workspace | |
ballCollider.Parent = ball | |
while true do | |
if ball.Parent == nil then | |
print("Ball physics stopped") | |
ballCollider:Destroy() | |
break | |
end | |
ballCollider.CFrame = camera.CFrame | |
for _, collider in CollectionService:GetTagged("BallCollider") do | |
local distance = (collider.Position - ball.Position).Magnitude | |
local isColliding = distance < (ball.Size.X * 2.8) | |
if isColliding then | |
local direction = (ball.Position - collider.Position).Unit | |
local directionXY = Vector3.new(direction.X, 0, direction.Z).Unit | |
velocity += directionXY * 2 | |
end | |
end | |
for i = 1, 10 do | |
local touching = ball:GetTouchingParts() | |
if #touching == 0 then | |
ball.CFrame -= Vector3.new(0, 0.1, 0) | |
end | |
for _, toucher in touching do | |
if toucher:CanCollideWith(ball) then | |
ball.CFrame += Vector3.new(0, 0.1, 0) | |
end | |
end | |
end | |
ball.CFrame = (ball.CFrame + velocity) * CFrame.Angles(velocity.X, velocity.Y, velocity.Z) | |
velocity *= 0.92 | |
task.wait() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment