this script is an assist script, it shows the person who assisted the goal scorer. however, if the goalscorer touches the ball twice, the script will think he scored the goal and he also assisted the goal. can someone help me add something to prevent this so that the same person cannot be the kicker & the assister at the same time?
function onTouch(Brick) local player = Brick.Parent:findFirstChild("Humanoid") if (player ~=nil) then script.Parent.Kicker.Value = player.Parent.Name wait(5) script.Parent.Assister.Value = script.Parent.Kicker.Value end end script.Parent.Touched:connect(onTouch)
If I am getting this right, you want the person who scored the Goal to be assigned to the Kicker value, and the kicker value ONLY?
To the point, what I see happening here is you have assigned the assistant value to be the Kicker value.
script.Parent.Kicker.Value = player.Parent.Name -- Define Kicker wait(5) script.Parent.Assister.Value = script.Parent.Kicker.Value -- Define Assister AS Kicker
Now I don't know how your code is organized as a whole, but to fix this you would need to find the Player who touched it before the Kicker. It could be done many different ways, but I might create a Table that would hold the most recent player to touch the ball, and the 2nd most recent player. This way you could get the value of the Kicker and The Assister much easier.
Of course, that's just what I might do. I'm sure there are more simpler, easier ways to do this.
Hopefully this was of some help to you. Let me know if you have any questions. :)