Still have questions? Join our Discord server and get real time help.
1

# Finding a players name to edit the properties inside of it?

Edited 2 years ago

I am busy making a roblox game and wanted to make a game that will remove a item from the players inventory and add some cash for it.....

My game is SO FAR robbing a bank but there is a part in which you can collect credit cards and put it into a ATM for cash....So basically I want for someone to pick up a card bring it to the ATM and insert it inside...Once they have done that it must remove their card from their inventory and add 1000\$ to their account.

===================================================================

MAIN PROBLEM: I know how to make clickable items to start a script for them to insert the card but I don't understand how to edit their properties because I do not have their name so I need to find how to get their name is find it in my PLAYERS properties.

====================================================================

1

This seems like a good time to use GetPlayerFromCharacter! GetPlayerFromCharacter is a function of Players. It has one argument. In that argument you put the character you want to get the player from, and than it returns the player that owns that character.

For example:

local player = game.Players:GetPlayerFromCharacter(game.Workspace.Player1)


Here is one that is more fitting to your situation.

script.Parent.Touched:connect(function(part)
if part.Name == "Credit Card" then -- Check to see if the part is credit card
if part.Parent.Parent:FindFirstChild("Humanoid") then -- See if a player is holding the credit card
local player = game.Players:GetPlayerFromCharacter(part.Parent.Parent) -- Get the player from the charecter
end
end
end)


I hope this solves your problem!

player.Backpack.CreditCard.Destroy()