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

can you help me make this script smarter?

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)

2 comments

0

explain what is supposed to happen

0

if a player touches ball his name will go on the Kicker Value. But if he passes the ball away and another player touches the ball, his name will go on the Assister value and that other player will go on the kicker value. please help

1 answer

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

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