I was trying to make a counter that pays for items and im trying to make the counter rename the tool.
Depends on the script's hierarchy.
If the script is inside the counter, the format for this depends on the variable for the player that is within the script:
If the player variable references the Model object (Character) and not the Player object, you'll have to do it this way:
-- local Player = whatever (e.g. local player = game:GetService("Players"):GetPlayerFromCharacter(otherPart.Parent).Character, but can be whatever) local tool = Player:FindFirstChild("CounterTool") or game:GetService("Players"):GetPlayerFromCharacter(Player).Backpack:FindFirstChild("CounterTool") -- If the tool is equipped, it'll go for the first: the tool in the player. If it's unequipped, it'll go through the "or" and find the Player object of the player, then search in the backpack for the tool. This works because tools naturally rest in the Backpack when unequipped. tool.Name = "RenamedTool" -- VoilĂ ! It is renamed! tool = Player:FindFirstChild("RenamedTool") or game:GetService("Players"):GetPlayerFromCharacter(Player).Backpack:FindFirstChild("RenamedTool") -- update the variable, because variables connected to properties don't change when their corresponding property does
If the player variable references the Player object, then you'll have it a bit easier:
-- local Player = whatever, e.g. game:GetService("Players"):GetPlayerFromCharacter(otherPart.Parent) local tool = Player.Backpack:FindFirstChild("CounterTool") or Player.Character:FindFirstChild("CounterTool") -- if they have it unequipped, bork bork, if they have it equipped, borf borf tool.Parent = "RenamedTool" -- yoy tool = Player.Backpack:FindFirstChild("RenamedTool") or Player.Character:FindFirstChild("RenamedTool") -- you know the drill
And voilĂ ! You have yourself a renamed tool!
If the script is inside the tool (which I doubt is the case):
script.Parent.Name = "Hello there" -- like RedcommanderV2 said