Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Traveling Script for Basketball Game Not Working?

Asked by 6 years ago
Edited 6 years ago

I only want it so that whenever I have the "LBA_Ball" in my hands, and it's not during Practice or Halftime, I want it during game, if I ever jump, that I would lose the ball, and give the other team the basketball.

Here's The Script: It's been buggy, but I tried my best, lol.

local d=true
local plr=game.Players.LocalPlayer
local display = game.Workspace.display
local char=plr.Character or plr.CharacterAdded:wait()
local ServStorage=game:GetService("ServerStorage")

plr.Character:WaitForChild("Humanoid").FreeFalling:connect(function(val)
    if d and char:FindFirstChild("LBA_Ball") and workspace.quarter.Value ~= "P" and workspace.quarter.Value ~= "H" 
    and val==false then 
        print('falling')
        wait(2)
    elseif d and char:FindFirstChild("LBA_Ball") and workspace.quarter.Value ~= "P" and workspace.quarter.Value ~= "H" 
    and val==true then
        wait(1.5) 
        print('on ground')
        d=false
            workspace.Sounds.Whistle:Play()
            wait(1)
            workspace.Sounds.Whistle:Play()
            wait(2)
            workspace.removal.Value=true
            workspace.timer.Disabled=true
            if plr.TeamColor==BrickColor.new("Bright blue") then
                display.Value="Traveling. Cavaliers Ball."
                wait(2)
                display.Value=""
            elseif plr.TeamColor==BrickColor.new("Bright red") then
                display.Value="Traveling. Warriors Ball."
                wait(2)
                display.Value=""
            end
            workspace.removal.Value=false
            workspace.shotclock.Value=24
            local c=game.Players:GetChildren()
            for i=1, #c do
                if c[i].TeamColor==BrickColor.new("Bright blue") then --Blue team
                    c[i].Character:moveTo(workspace.pos2.Position,workspace.pos2) --Position
                elseif c[i].TeamColor==BrickColor.new("Bright red") then --Red team
                    c[i].Character:moveTo(workspace.pos1.Position,workspace.pos1) --Position
                end
            end
            if char.TeamV.Value == BrickColor.new("Bright blue") then
                wait(1)
                workspace.Sounds.Whistle:Play()
                local ball=ServStorage.LBA_Ball:Clone()
                wait()
                ball.Parent=workspace
                ball.Handle.Position=workspace.pos2.Position
                workspace.timer.Disabled=false
            elseif char.TeamV.Value == BrickColor.new("Bright red") then
                wait(1)
                workspace.Sounds.Whistle:Play()
                local ball=ServStorage.LBA_Ball:Clone()
                wait()
                ball.Parent=workspace
                ball.Handle.Position=workspace.pos2.Position                
                local ball=ServStorage.LBA_Ball:Clone()
                wait(2)
                ball.Parent=workspace
                ball.Handle.Position=workspace.pos1.Position
                workspace.timer.Disabled=false
            end
            repeat wait() until not workspace:FindFirstChild("LBA_Ball")
        end
    wait(5)
    d=true
end)

Thanks, LukeGabrieI

Answer this question