Took a long break from coding and im getting back into it but forgot how to get a player from the character when the character hit a part. Its so when the player hits the part they get 5 coins.
Code
local coin = game.Workspace.coin
coin.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = hit:GetPlayerFromCharacter(hit.Parent)
player.leaderstats.Coins.value = player.leaderstats.Coins.value + 5
end
end)
Error message
23:35:27.588 GetPlayerFromCharacter is not a valid member of MeshPart "Workspace.bestshot123.LeftHand" - Server - Script:4

2 comments
It seems you've got a bit confused. Change line 4 to this; local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
That worked^