I wish that when the player touches the part he receives 10 cash, but my script does not work
function Touched(h)
local player = h.Parent
player.leaderboard.Cash.Value = 10
end
script.Parent.Touched:Connect(Touched)
I wish that when the player touches the part he receives 10 cash, but my script does not work
function Touched(h)
local player = h.Parent
player.leaderboard.Cash.Value = 10
end
script.Parent.Touched:Connect(Touched)
Use GetPlayerFromCharacter with Players
function Touched(h)
local Player = game:GetService('Players'):GetPlayerFromCharacter(h.Parent) -- Find the client
if Player then
Player.leaderstats.Cash.Value = Player.leaderstats.Cash.Value + 10 -- 100 + 10 = 110 and not 0 = 10
end
end
script.Parent.Touched:Connect(Touched)
-- 2
script.Parent.Touched:Connect(function(h)
local Player = game:GetService('Players'):GetPlayerFromCharacter(h.Parent) -- Find the client
if Player then
Player.leaderstats.Cash.Value = Player.leaderstats.Cash.Value + 10 -- 100 + 10 = 110 and not 0 = 10
end
end
This discussion is preserved as it was. New answers, comments, and votes are closed.