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

How do i make this script runs only on me?

Asked by
Xianon 105
10 years ago

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

Log in to vote
2
Answered by
MrFlimsy 345 Moderation Voter
10 years ago

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!

0
lol, Thanks din't notice the quotation marks. Xianon 105 — 10y
Ad

Answer this question