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

How to detect a Guest with a script?

Asked by
Andrwo 0
10 years ago

Well, i'm making a game where you collect coins to buy more cars, but I want that, when a guest Joins a game, a GUI (notification appears) and says, that you're a guest and your progress won't be saved, but I only need the script to detect the guest. Thanks! ;)

2 answers

Log in to vote
4
Answered by 10 years ago

You would need to check the name and have a GUI ready to make visible if they're a guest. Here is the way I think would work best:

1GUI = script:FindFirstChild("GUI") -- Find the GUI
2 
3if script.Parent.Name:sub(1,6) == "Guest " then -- Check the first 6 letters for a guest's name.
4    GUI:Clone().Parent = script.Parent -- Clone the GUI and change the parent to PlayerGui.
5    GUI.Frame.Visible = true -- Make the main thing visible.
6end

You will need to have something like a confirm button to close it or add a timer then remove it. Hope this helps, if it does please leave a vote up, it doesn't hurt to click a button!

Ad
Log in to vote
2
Answered by 10 years ago

in order to detect a guest, do this:

1local plr = game.Players.LocalPlayer
2game.Players.PlayerAdded:connect(function(plr)
3if plr.AccountAge == (0) then
4-- code here
5end
6end)

or, this:

1local plr = game.Players.LocalPlayer
2game.Players.PlayerAdded:connect(function(plr)
3if plr.Name:sub(1,6) == "Guest " then
4-- code here
5end
6end)

hope this helped!

Answer this question