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

How do i add field goals to my game so after touchdown you kick an extra point?

Asked by 8 years ago

Ok I already have the football kick script and the kicker running up script. I just wanna know how to add them in the game to work after a touchdown and give an extra point. HELP (I can only add some of the master script.

--Heres the master script for the game--

_G.didIt=function()


---define variables---

local hiked=workspace.hiked;--if the ball has been hiked local Ready=false;--for when it is setting up local DownDisp=workspace.DownDisp;--ObjectValue( String ) display for scoreboard and check for setup local down=0;--current down local play_time=0;--amount of time used in the play local sneaked=workspace.sneaked;--did the QB sneak or not? local SNEAK_TIME=0;--how long the QB has to wait before being able to sneak local position=workspace.position;--ObjectValue( Number ) for line markers local possesion=workspace.possesion;--ObjectValue( Boolean ) for who has the ball local box=workspace.TeamChooser;--the team choosing box local Replaying=false;--is there an instant replay running? local teamsPicked=false;--have the teams been successfully divided? _G.Plays={};--for the recent play display --[[ true=red false=blue --]] local yargo=0;--number of penalty yards local first=0;--first down point local quarter=0;--current quarter local Teams=game.Lighting.Teams;--the different teams local home;--home team local away;--away team local ballcarrier;--players character that has the ball local h=Instance.new("Hint",workspace);--hint for display stuff h.Text="2 or more players needed to start a game."; h.Name="h"; local walls=workspace.Walls;--containment for before the game local TD=false;--tells if there was a touchdown local EP=false;--tells if there was a extra point scored local safety=false;--tells if there was a safety local caught,thrown=false,false;--thrown and caught local Fix=workspace.Fix;--fix the server local ball=workspace.Ball;--the ball local int=false;--intercepted local qb=workspace.qb;--the person who hikes it, no sneaks anymore local penalty=false;--if they do something I deem wrong local Tak=workspace.Tak;--who tackled em boi local done=workspace.done;--checks for if everything is over with local kickoff=false;--says if it's a kickoff or not local illegal_kick=false;--illegal kick local touchback=false;--touchback local fumbled=workspace.fumbled;--ball was fumbled local kicked=false --if the ball is punted

local Replaying=false;--is there an instant replay running?

---define functions---

--deletes an object function delete(obj) game:GetService("Debris"):AddItem(obj,0); end

--++PAT's++--

THIS IS WHERE I WANT THE PAT CODE TO GO

--++PUNTING++--

--Coming Soon!

--Does an Instant Replay

function Replay() Replaying=true; workspace.IR.ShowReplay.Value=true; repeat Wait(); until not workspace.IR.ShowReplay.Value Replaying=false; end

--sends a message to all the players in the game _G.message=function(msg,dur,color) for _,v in pairs(game.Players:GetChildren()) do v.PlayerGui.disp.msg.TextColor3=color or Color3.new(); v.PlayerGui.disp.msg.Text=msg; end Delay(dur or 3,function() for _,v in pairs(game.Players:GetChildren()) do v.PlayerGui.disp.msg.Text=""; end end ); end

--gives a pretty display of time passed. Takes in seconds. function timer(seconds) local milliseconds=seconds%1;--gets the decimal from the number local seconds=seconds-milliseconds;--whole number seconds return math.floor(seconds/60)..--minutes (seconds%60>=10 and ":" or ":0")..tostring(seconds%60)--..--seconds --":"..("%0.3f"):format(milliseconds):sub(3);--milliseconds end

--randomly sort teams function randomTeams() local tab1={}; for _,v in pairs(game.Players:GetPlayers()) do table.insert(tab1,math.random(#tab1+1),v); end for i,v in ipairs(tab1) do v.TeamColor=i%2==0 and away.TeamColor or home.TeamColor; v:LoadCharacter(); end end

-- Count how many players are on each team and neutral except -- do not count the specified player. local function countTeams(player)

local rteam = 0
local bteam = 0
local neutral = 0

for k,v in pairs(game.Players:GetChildren()) do

    if v ~= player then

        if v.Neutral then
            neutral = neutral + 1

        elseif v.TeamColor == away.TeamColor then
            rteam = rteam + 1

        elseif v.TeamColor == home.TeamColor then
            bteam = bteam + 1

        else
            neutral = neutral + 1

        end
    end
end

return rteam, bteam, neutral

end


local function chose(player, selectedTeam) if (not player.Neutral) and ((player.TeamColor == away.TeamColor) or (player.TeamColor == home.TeamColor)) then return end

-- Count current teams (except our player)
local rteam, bteam, neutral = countTeams(player)

-- Add in our player to the neutral count
neutral = neutral + 1

local total = rteam + bteam + neutral

if selectedTeam == away.TeamColor then
    if rteam < bteam + neutral then 
        player.Neutral = false
        player.TeamColor = away.TeamColor
        player:LoadCharacter();
    else
        return
    end
elseif selectedTeam == home.TeamColor then
    if bteam < rteam + neutral then 
        player.Neutral = false
        player.TeamColor = home.TeamColor
        player:LoadCharacter();
    else
        return
    end
end

end

--allows players to pick their own teams function playerChoice() p_choice=true; for _,v in pairs(game.Players:GetPlayers()) do v:LoadCharacter(); while not v.Character:findFirstChild("Torso") do Wait(); end v.Character.Torso.CFrame=box.Middle.CFrame*CFrame.new(math.random()*2-1,3.5,math.random()*2-1); end for i=60,0,-1 do Wait(1); h.Text=timer(i); end local tab1={}; for _,v in pairs(game.Players:GetPlayers()) do if v.TeamColor==BrickColor.new("Really black") then table.insert(tab1,math.random(#tab1+1),v); end end for i,v in ipairs(tab1) do local gt,bt,neut=countTeams(v); if gt==bt then v.TeamColor=i%2==0 and green.TeamColor or blue.TeamColor; else if gt<bt then v.TeamColor=away.TeamColor; else v.TeamColor=home.TeamColor; end end end end

--Have team captains pick teams, race to find captains function captains() --reset values p_choice=false; cap0,cap1=nil,nil;--the captains --spawn players local captain_count=0; local last_captain; for ,v in pairs(game.Players:GetPlayers()) do if game:GetService("GamePassService"):PlayerHasPass(v,133311293) then captain_count=captain_count+1; last_captain=v; end end if captain_count==1 then cap0=last_captain; cap0.TeamColor=away.TeamColor; end for _,v in pairs(game.Players:GetPlayers()) do v:LoadCharacter(); while not v.Character:findFirstChild("Torso") do Wait(); end if not game:GetService("GamePassService"):PlayerHasPass(v,133311293) then Spawn(function() v.PlayerGui.capAd.Button.Visible=true; Wait(8); v.PlayerGui.capAd.Button.Visible=false; end ); end if game:GetService("GamePassService"):PlayerHasPass(v,133311293) or captain_count&lt;2 then v.Character.Torso.CFrame=box.Blue.CFrame*CFrame.new(math.random()*2-1,3.5,math.random()*2-1); end end --wait for the race for captains to end repeat Wait(); until cap0 and cap1 --have captains pick and stuff message("Captains for both teams have been decided.",5); local cap_display=game.Lighting.CAP:clone();--the captains GUI _G.cur_pick=false;--false==0 true==1 cap_display.Parent=cap0.PlayerGui; local neuts=0;--neutral people left --repeat until nobody left repeat Wait(); --re-parent GUI if not cap1:findFirstChild("PlayerGui") or not cap0:findFirstChild("PlayerGui") then if _G.cur_pick and not cap1 then _,,neutral=countTeams(); local pick=neutral[math.random(#neutral)]; pick.TeamColor=home.TeamColor; G.cur_pick=not _G.cur_pick; elseif not _G.cur_pick and not cap0 then _,,neutral=countTeams(); local pick=neutral[math.random(#neutral)]; pick.TeamColor=away.TeamColor; G.cur_pick=not _G.cur_pick; end else if not pcall(function() cap_display.Parent=_G.cur_pick and cap1.PlayerGui or cap0.PlayerGui; end) then _,,neutral=countTeams(); local pick=neutral[math.random(#neutral)]; pick.TeamColor=G.cur_pick and home.TeamColor or away.TeamColor; _G.cur_pick=not _G.cur_pick; end end --check team count _,,neuts=countTeams(); until neuts<=0 teamsPicked=true; end

--green brick touched function greenTouched(part) --players choose teams if p_choice then local playa=game.Players:GetPlayerFromCharacter(part.Parent); if playa then chose(playa,away.TeamColor) end --captains race else if not cap0 then local playa=game.Players:GetPlayerFromCharacter(part.Parent); if playa and playa.TeamColor==BrickColor.new("Really black") then cap0=playa; playa.TeamColor=away.TeamColor; end elseif not cap1 then local playa=game.Players:GetPlayerFromCharacter(part.Parent); if playa and playa.TeamColor==BrickColor.new("Really black") then cap1=playa; playa.TeamColor=home.TeamColor; end end end end

--blue brick touched function blueTouched(part) if p_choice then local playa=game.Players:GetPlayerFromCharacter(part.Parent); if playa then chose(playa,home.TeamColor) end end end

--runs voting stuff to decide game modes f

0
Could you fix your scripts, they're not in 'Code Block'. Extremely hard to read atm. iFlusters 355 — 8y

Answer this question