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

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

Asked by 7 years ago
Edited 7 years ago

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

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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! :)

Ad

Answer this question