This script is a part of a buybutton of a tycoon i made, which checks if you have money, if not, it prompts you to get some. But if you are a guest, it was supposed to invite you to register at ROBLOX. But, I entered the game as a guest, and I got the wrong GUI! Why?
Script below:
script.Parent.Head.Touched:connect(function(h) if not deb then deb = true if game.Players:FindFirstChild(h.Parent.Name) then if h.Parent.Name == script.Parent.Parent.Parent.OwnerShipSystem.Owner.Value then local playername = h.Parent.Name if game.Players[playername].leaderstats.Money.Value >= cost then game.Players[playername].leaderstats.Money.Value = game.Players[playername].leaderstats.Money.Value - cost backup.Parent = script.Parent.Parent.Parent.Factory print("Transaction completed! :)") script.Parent:Destroy() elseif playername == string.sub(playername,1,6) == "Guest " then print ("The owner hasn't money... and it is a guest.") local neofg = game.ServerStorage.GUI.NotEnoughMnyForGuests:Clone() neofg.Parent = game.Players:FindFirstChild(h.Parent.Name).PlayerGui else print ("The owner hasn't money.") local neo = game.ServerStorage.GUI.NotEnoughMny:Clone() neo.Parent = game.Players:FindFirstChild(h.Parent.Name).PlayerGui end else print ("This player isn't the owner") local nto = game.ServerStorage.GUI.NotTheOwner:Clone() nto.Parent = game.Players:FindFirstChild(h.Parent.Name).PlayerGui wait(3) nto:Destroy() end else print("This isn't a player") end deb = false end end)
Instead of checking the name, check it's userId. All guests have negative userIds. The problem was you had multiple "=="s on one line. Use an and instead. It's better to see it's user id though.
script.Parent.Head.Touched:connect(function(h) if not deb then deb = true if game.Players:FindFirstChild(h.Parent.Name) then if h.Parent.Name == script.Parent.Parent.Parent.OwnerShipSystem.Owner.Value then local playername = h.Parent.Name if game.Players[playername].leaderstats.Money.Value >= cost then game.Players[playername].leaderstats.Money.Value = game.Players[playername].leaderstats.Money.Value - cost backup.Parent = script.Parent.Parent.Parent.Factory print("Transaction completed! :)") script.Parent:Destroy() elseif game.Players[playername].userId > 0 then print ("The owner hasn't money... and it is a guest.") local neofg = game.ServerStorage.GUI.NotEnoughMnyForGuests:Clone() neofg.Parent = game.Players:FindFirstChild(h.Parent.Name).PlayerGui else print ("The owner hasn't money.") local neo = game.ServerStorage.GUI.NotEnoughMny:Clone() neo.Parent = game.Players:FindFirstChild(h.Parent.Name).PlayerGui end else print ("This player isn't the owner") local nto = game.ServerStorage.GUI.NotTheOwner:Clone() nto.Parent = game.Players:FindFirstChild(h.Parent.Name).PlayerGui wait(3) nto:Destroy() end else print("This isn't a player") end deb = false end end)
Hope it helps!