Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make it if I'm trying to change a value when a ball enters a goal?

I've explored multiple scripts. But the NumberValue, fifa, will not change when the soccerball hits this part.

Here's my latest script:

script.Parent.Touched:connect(function(hit)
if hit.Name == "HumanoidRootPart" or hit.Name == "Handle" or hit.Name == "Right Leg" or hit.Name == "Left Leg" or hit.Name == "Torso" or hit.Name == "Head" or hit.Name == "Right Arm" or hit.Name == "Left Arm" then
game.Workspace.fifa.Value = workspace.fifa.Value+1
end
end)

Thank you for your time in advance!

1 answer

✓ Accepted answer

It looks like the score only goes up when a Character touches the part the script is located in. If you're trying to get a point to score when a soccer ball touches the goal, you'll need to change up the script.

I've demonstrated below what you need to change in order to get this to work. Place the following script inside a part in the goal, and change the soccerName value to the name of your soccer ball part.

local soccerName = "Ball" -- Change this value to the name of your soccer ball part.

script.Parent.Touched:connect(function(hit)
	if hit.Name == soccerName then
		game.Workspace.fifa.Value = workspace.fifa.Value+1
	end
end)

Make sure to accept if I helped! :)

This discussion is preserved as it was. New answers, comments, and votes are closed.