I’d like to change the part name to the player’s name
Here’s an example of what I’m aiming for, but it doesn’t just include my players’ names.
(I did this manually)
I tried doing game.Players.LocalPlayer or game.Character but none of them work.
I’d like to change the part name to the player’s name
Here’s an example of what I’m aiming for, but it doesn’t just include my players’ names.
(I did this manually)
I tried doing game.Players.LocalPlayer or game.Character but none of them work.
So is it in normal Script or Local script?
If it’s a normal Script so you want it to be replicated across both client and server you need to do something like this:
game:GetService("Players").PlayerAdded:Connect(function(player)
local Part = Instance.new("Part")
Part.Name = player.Name
Part.Parent = workspace
end)
local Players = game:GetService('Players')
local Part = nil
Part.Touched:Connect(function(stuff)
if stuff.Parent:FindFirstChild('Humanoid') then
local b = stuff.Parent
local player = Players:GetPlayerFromCharacter(b)
print(('%s farted on the part'):format(player.Name))
local part = Instance.new('Part')
part.Name = player.Name
end
end)
It was in normal Script and not a Local Script.
Edited my post go check it out.
You need to reference Player variable somehow in my script I showed you Making new part and name it with name of player that joined the game.
Oh I see @p49p0 already gave solution.
It gave me an error
i mean change the Part to the part location
nil = nothing
I tried yours, but It doesn’t send a part from the folder.
Sorry it is just an example not fully working script.
LocalPlayer
is only available on the client.
Oh I see, I was confused in there, thanks for the correction.
To get the “player”, you could do something like for example:
game.Players.PlayerAdded:Connect(function(player)
projectile.Name = player.Name
end)
I don’t know your full code, it would help if perhaps you could post it.
(Replied to wrong person, I’m replying to @kachupiyt )