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! ;)
COMMUNITY QUESTION
How to detect a Guest with a script?
2 answers
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!
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!
This discussion is preserved as it was. New answers, comments, and votes are closed.
