0

# How do I trigger a script when a certain body part touches a part?

In my game, if the player steps on a certain pad they will be granted +10 coins. Here is the script I'm using:

script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then wait(0.4)
game.Players:FindFirstChild(hit.Parent.Name).moneystats.Coins.Value += 10
wait (5)
end
end)


This script works, but it has an issue. If it registers both legs landing on the pad at once, (such as when a player jumps on to it), it will execute the script twice and award 20 coins. I tried to fix this by awarding the coins only if the left leg touched the pad. That way, the script will not be triggered twice if both legs touch at the same time. To do this, I used the above script but changed ("Humanoid") to ("LeftLeg"):

script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("LeftLeg") then wait(0.4)
game.Players:FindFirstChild(hit.Parent.Name).moneystats.Coins.Value += 10
wait (5)
end
end)


However, this script resulted in no coins being awarded. Does anyone know how to fix the script so the coins will be awarded only when the left leg touches the pad?

0
Your script will probably work if the player's body type is r6. Already try it on r6? The_Saver31 32 — 15d
0
Yes, I made the game for r6, and that is what I have been testing in. verrdin 0 — 15d
0
Its because its not a ("LeftLeg") on the R6 but its ("Left Leg") The_Saver31 32 — 15d

0
script.Parent.Touched:Connect(function(hit)