Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 5 years ago
Edited 5 years ago

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?

0
you need to put player in speech marks tonyv537 95 — 5y
0
"player" tonyv537 95 — 5y
0
or put player.Name ( if its the player name you want tonyv537 95 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago
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)
1
Oh wow I feel dumb hamburger621 34 — 5y
0
we all have those moments B) Gey4Jesus69 2705 — 5y
1
anytime i try to answer, your answer gets there first tonyv537 95 — 5y
0
accidental?? :)) Gey4Jesus69 2705 — 5y
View all comments (2 more)
1
coinsidence? Maybe? Hotel Trivago tonyv537 95 — 5y
0
Player references to the Player Object, .Name references to their Name, which is a String Ziffixture 6913 — 5y
Ad

Answer this question