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

how can i make these two scripts into one?

Asked by 9 years ago

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)

1 answer

Log in to vote
1
Answered by 9 years ago

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
Ad

Answer this question