This is the cash script
local part = script.Parent local cash = part.Parent.Money part.Transparency = 1 part.Position = cash.Position part.Touched:Connect(function(hit) local player = hit.Parent if player:FindFirstChild("Humanoid").Health > 0 then if player.Name == game.Players.THIS_IS_THE_PROBLEM.Name then game.Players.THIS_IS_THE_PROBLEM.leaderstats.Cash.Value = game.Players.THIS_IS_THE_PROBLEM.leaderstats.Cash.Value +3 end end end)
I could just put my name there, but i need to somehow get the name of the player that touched hitbox from game.Players tab.
A good way to do this is to use :GetPlayerFromCharacter. Learn more here: https://developer.roblox.com/en-us/api-reference/function/Players/GetPlayerFromCharacter
local moneyGain = 3 local part = script.Parent local cash = part.Parent.Money part.Transparency = 1 part.Position = cash.Position part.Touched:Connect(function(hit) local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) if player then if player.Name == "Username" then player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + moneyGain end end end)
local part = script.Parent local cash = part.Parent.Money part.Transparency = 1 part.Position = cash.Position cash = player.leaderstats.Cash part.Touched:Connect(function(hit) local player = hit.Parent if player:FindFirstChild("Humanoid").Health > 0 then if player.Name == "DenchikRus" then -- replace USER with your name DenchikRus.cash.Value = cash.Value +3 end end end)