Help with Scoring function

I am making a soccer game, I want the status – (the textlable), to say the specific player that scored but I cant get the player, with my knowledge

heres my function

local function score(team)
	team.Text = team.Text + 1   -- adds a point to a teams textlable
	status.Text = team.Name.." Scores!" -- I only can get the team that scored though
	ball.Anchored = true  -- the ball is the ball you hit the goal with
	wait(5)
	status.Text = ""
	resetTeams()
	resetBall(1)
end

thanks!

1 Like

make a attribute in the ball that stores the last players name that touched it

How would I do that?

[Ignore this text]

image

then you use scripts ---------------

ok thanks!

although alvinblox didnt help me enough with attributes

ball = script.Parent
local att = ball:GetAttribute("LastTouch")


ball.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChildOfClass("Humanoid") then
		att = hit.Parent.Name
	end
	
end)

this script I tried doesnt work
nothing is in output, string text doesnt change

(was it supposed to be a string?)

You’re trying to add 1 to a string. Try:

tonumber(team.Text) +=1

Also, use task.wait instead of wait.

no, that part is ok, its the attribute, im trying to get the attributes text to be the players name who last touched it