im trying to make a script to spawn coins and when the player touches the coin it gives them 10 coins in the leaderstats but i keep getting this same error
and heres the script
You don’t get the player from newpart.Touched
, only hit. It should look like this instead:
newpart.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
-- give the player coins here
end
end
end)
(Unrelated, but this is supposed to be #help-and-feedback #help-and-feedback:scripting-support)
1 Like