Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does my output stay that it got an object instead of a string?

i just used the .Name to name a folder I made the same as the name of a player:

local f

function onPlayerEntered(player)
	f = Instance.new("Folder")
	f.Name = player
	f.Parent = game.Lighting
	print("Folder created")
end

game.Players.PlayerAdded:connect(onPlayerEntered)

But when I start the server outputs: 17:46:07.681 - Workspace.Main.Script:7: bad argument #3 to 'Name' (string expected, got Object)

why does it do this and how can I fix it?

3 comments

0

you need to put player in speech marks

0

"player"

0

or put player.Name ( if its the player name you want

1 answer

✓ Accepted answer
local f

function onPlayerEntered(player)
    f = Instance.new("Folder")
    f.Name = player.Name --use the name property
    f.Parent = game.Lighting
    print("Folder created")
end

game.Players.PlayerAdded:connect(onPlayerEntered)

6 comments

1

Oh wow I feel dumb

0

we all have those moments B)

1

anytime i try to answer, your answer gets there first

0

accidental?? :))

1

coinsidence? Maybe? Hotel Trivago

0

Player references to the Player Object, .Name references to their Name, which is a String

This discussion is preserved as it was. New answers, comments, and votes are closed.