hi guys, these functions do the exact same thing so can someone help me make them into 1 function instead of two
workspace.Footy.Red.Goal.Changed:connect(function() script.Parent.Frame.Scorer.Text = "GOAL - " .. workspace.Goals.Ball.LastKick.Value:upper() .. " GOALS -" .. game.Players:FindFirstChild(workspace.Goals.Ball.LastKick.Value).leaderstats.Goals.Value script.Parent.Parent.ImageLabel.Image = "http://www.roblox.com/asset/?id=" .. game.Players:FindFirstChild(workspace.Goals.Ball.LastKick.Value).hiddenstats.flagy.Value script.Parent.Frame.Time.Text = workspace.minutes.Value .. "'" script.Parent.Parent.Visible = true wait(25) script.Parent.Parent.Visible = false end) workspace.Footy.Blue.Goal.Changed:connect(function() script.Parent.Frame.Scorer.Text = "GOAL - " .. workspace.Goals.Ball.LastKick.Value:upper() .. " GOALS -" .. game.Players:FindFirstChild(workspace.Goals.Ball.LastKick.Value).leaderstats.Goals.Value script.Parent.Parent.ImageLabel.Image = "http://www.roblox.com/asset/?id=" .. game.Players:FindFirstChild(workspace.Goals.Ball.LastKick.Value).hiddenstats.flagy.Value script.Parent.Frame.Time.Text = workspace.minutes.Value .. "'" script.Parent.Parent.Visible = true wait(25) script.Parent.Parent.Visible = false end)
You need to do this:
function Change() script.Parent.Frame.Scorer.Text = "GOAL - " .. workspace.Goals.Ball.LastKick.Value:upper() .. " GOALS -" .. game.Players:FindFirstChild (workspace.Goals.Ball.LastKick.Value).leaderstats.Goals.Value script.Parent.Parent.ImageLabel.Image = "http://www.roblox.com/asset/?id=" .. game.Players:FindFirstChild(workspace.Goals.Ball.LastKick.Value).hiddenstats.flagy.Value script.Parent.Frame.Time.Text = workspace.minutes.Value .. "'" script.Parent.Parent.Visible = true wait(25) script.Parent.Parent.Visible = false end workspace.Footy.Blue.Goal.Changed:connect(Change) --Calls Change() if blue goal changes, workspace.Footy.Red.Goal.Changed:connect(Change) -- Or red goal