I Basically need help on how to script a few things. 1st, if the player leaves the game the text will reset back to the original. 2nd, a script only allowing a player to claim one dorm at a time and is unable from trying to claim a claimed dorm (they are still able to claim a unclaimed dorm, it would just unclaim there last dorm Allowing others to claim). 3rd, if a player already has claimed a dorm, it doesn't continue to give them a key when the button is clicked.
local p = game.Players.LocalPlayer script.Parent.MouseButton1Click:connect(function() if p.Backpack:FindFirstChild("Key")or p.StarterGear:FindFirstChild("Key")or game.Workspace[p.Name]:FindFirstChild("Key")then script.Parent.Text = "Dorm Claimed" wait(1) script.Parent.Text = p.Name else local tool = game.ServerStorage.Key:Clone() tool.Parent = p.Backpack script.Parent.Text = p.Name end end)
--you can put this script in the textbox local name=script.Parent.Text --name of the player local player=game.Players:FindFirstChild(name) -player player.PlayerRemoving:connect(function() --when the player leaves it changes the text script.Parent.Text="Unclaimed" end)
--you can also put this script in the same one as above it will check if the player already owns a -- dorm this is what i would do to check, I recommend making a model or folder with a bunch of --string values inside and whenever someone gets a dorm for the first time change one of the --values to the users name that way we can check if he has one there are other methods of --doing it but that's the way I would do it for _, v in pairs(game.Workspace.DormChecks:GetChildren()) do if v.Value==hit.Parent.Name then print("already has one") else print("give the guy a dorm") end
3rd third can be done in second where it says give the guy a dorm, if you have any questions let me know