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

Can someone help me with this code?

Asked by 8 years ago

This code isn't working:

if key_code == 13 then
game.Players.PlayerAdded:connect(function(Player)
    game.Workspace.Billboard.Screen.Front.Label1.Text = Player.Name.." pressed the button"
    end)

I'm getting this error: "attempt to index field 'Name' (a string value)"

I'm pretty sure this code is really messed up but I just want it to say "[Player name] pressed the button" when a player presses key code 13.

0
Is this ALL your code? Perci1 4988 — 8y
0
No, there is some other code. This is just the portion that's giving me the error. intrance 50 — 8y
0
At least post the KeyDown event connect and stuff. Perci1 4988 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

First of all, your code makes no sense at all. PlayerAdded is for when a player joins the game, so your code would never even work. I have changed your code to work.

local player = game.Players.LocalPlayer
if key_code == 13 then
        game.Workspace.Billboard.Screen.Front.Label1.Text = player.Name .. " pressed the button."
end
0
Thank you so much! intrance 50 — 8y
Ad

Answer this question