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
On line 4 you put just "hit" before GetPlayerFromCharacter. This means that it will go to the body part, which in this case was the left hand. Change it to hit.Parent, because the parent of the left hand has the actual character. So your new line 4 would be
local player = hit.Parent:GetPlayerFromCharacter(hit.Parent)