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

How do i make this script runs only on me?

I want to make this script runs on me and my friend, but after testing and fixing several times i couldn't found out what's wrong with it.

local F3X = script.Parent
local label = game.Workspace.Cool.SurfaceGui.Frame.TextLabel


game.Players.PlayerAdded:connect(function(player)
	
	
	if game.Players.Name == Xianon then 
		 label.Text = ("Welcome Xianon")
		msg.Text = ("Xianon has entered the game")
		wait (3)
		msg:remove()
		
		
		elseif not game.Players.Name == Xianon then
			game.Players.Name.Backpack.BT:Destroy()
			
	
	
	if game.Players.Name == ApolloTalentz then
		label.Text = ("Welcome Apollo")
		msg.Text = ("Apollo has entered the game")
		wait(3)
		msg:remove()
		
		elseif not game.Players.Name == ApolloTalentz then
			game.Players.Name.Backpack.BT:Destroy()
	end
	end
end)

1 answer

✓ Accepted answer

Here's the problematic code:

if game.Players.Name == Xianon then

and,

if game.Players.Name == ApolloTalentz then

You're trying to check the name of game.Players, which is the service that holds all the players connected to the game. Since you used "player" as the parameter in the PlayerAdded event, you should instead use this:

if player.Name == "Xianon" then

Also notice how I put quotation marks around Xianon. This is because the Name property of a Player instance is a string, and Lua requires strings to be surrounded by quotation marks.

Hope this helps!

1 comment

0

lol, Thanks din't notice the quotation marks.

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