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

Could someone point me in the right direction on how to find the name of a character?NOT SOLVED..

Asked by 9 years ago

Hello. This script is for a player only game that is under development. Instead of a password GUI, I want it to just let me and my friend in. Thanks for helping.

Pass= script.Parent.Parent.Parent.Passcode

function Clicked()
    for i=1, 10 do
    wait(0.1)
    script.Parent.ImageTransparency = script.Parent.ImageTransparency +0.1
    end --after this i want this to check if the person who clicked is either the user "123thatalt" or "mendez3581" or "Player1"
    wait(0.3)
    script.Parent.Parent.Visible = false
    for b=1,30 do
    wait(0.001)
    Pass.Position = Pass.Position + UDim2.new(0, 7, 0, 0)
    end
end


script.Parent.MouseButton1Down:connect(Clicked)
0
Is this in a LocalScript? What is the parent of script? A TextButton? Merely 2122 — 9y
0
Parent is a textbutton, yes. And it is in a reg. script. My_Comment 95 — 9y

2 answers

Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

Make this a LocalScript, and try with this code:

Pass= script.Parent.Parent.Parent.Passcode

allowed = {player1 = true, mendez3581 = true, ["123thatalt"] = true}

function Clicked()
    for i=1, 10 do
    wait(0.1)
    script.Parent.ImageTransparency = script.Parent.ImageTransparency +0.1
    end
    if not allowed[Game.Players.LocalPlayer.Name:lower()] then return end --function will exit if not in the 'allowed' dictionary above.
    wait(0.3)
    script.Parent.Parent.Visible = false
    for b=1,30 do
    wait(0.001)
    Pass.Position = Pass.Position + UDim2.new(0, 7, 0, 0)
    end
end


script.Parent.MouseButton1Down:connect(Clicked)
0
I tried and the "allowed" script is broken (malformed number) And Im pretty sure that "allowed" is not recognized by LUA. My_Comment 95 — 9y
0
Lua* and look above the function definition. The malformed number is because I forgot to string-ify the username that starts with numbers. adark 5487 — 9y
Ad
Log in to vote
-3
Answered by
iLegitus 130
9 years ago

This should be inside Localscript,Starterpack.

Player = game.Players.LocalPlayer

if Player.Name == "YOURNAMEHERE" or "YOURFRIENDSNAMEHERE" then

script:remove()

else

Player:remove()

end

Hope it helped :P

0
Didnt work, but thanks for trying :) My_Comment 95 — 9y
0
That if statement always passes: string literalys are truthy, and you didn't do a comparison after the 'or' adark 5487 — 9y

Answer this question