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

Can someone help me with this code?

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.

3 comments

0

Is this ALL your code?

0

No, there is some other code. This is just the portion that's giving me the error.

0

At least post the KeyDown event connect and stuff.

1 answer

✓ Accepted answer

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

1 comment

0

Thank you so much!

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