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

Would this logically make sense?

Asked by
6zk8 95
4 years ago
Edited 4 years ago

Im making a tycoon and I am trying to add to my script to see if the owner of the tycoon left.

Im wondering if this would work:

val = script.Parent.OwnerText.SurfaceGui.TextLabel
pl = game:GetService("Players")

if val.Text ~= "No Owner" and pl:FindFirstChild(tostring(val.Text)) == false then
  print("Owner left so no owner")
end

Please answer/help with my question! Thanks.

0
Well, it should work but, there is a better way to doing this using game.Players.PlayerRemoving. mixgingengerina10 223 — 4y
0
Could you make an answer explaining it please? 6zk8 95 — 4y
0
Question tho, is this script located under the tycoon? mixgingengerina10 223 — 4y
0
Basically, it's in the owner door part. 6zk8 95 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

Sample script of what I mentioned in the comments:

local Owner = --The tycoon owner value

game.Players.PlayerRemoving:Connect(function(player) --A function that is activated when a player leaves
    if player.Name == Owner.Value then --Check if that player that left was the owner of the tycoon
        print("Owner has left the game")
        --Rest of your code here
    end
end)
0
Thanks! 6zk8 95 — 4y
Ad

Answer this question