When the part from the character touches the coin, the coin gives them their currency. But the coin will only look for the part and nothing else.
part:
Coin:
Coin script:
local part = script.Parent.Base -- it's the base part of the coin model!
part.Touched:Connect(function(hit)
if hit.Name == "PlayerBall" then
print(hit.Name)
local character = hit.Parent.Parent -- the parent of the ball = the HumanoidRootPart, and the parent of HumanoidRootPart = the character
local player = game.Players:GetPlayerFromCharacter(character)
if player then
player.leaderstats.Coins.Value += 1 -- add a coin to the player's coins value
part::Destroy() -- destroy the coin part so it can't be collected again
end
end
end)