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:

GUI = script:FindFirstChild("GUI") -- Find the GUI

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

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:

local plr = game.Players.LocalPlayer
game.Players.PlayerAdded:connect(function(plr)
if plr.AccountAge == (0) then
-- code here
end
end)

or, this:

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

hope this helped!

Answer this question