Ad
Log in to vote
0

I'm Developing a Dorm Script and i Need some assistance on how to do some things?

Asked by 9 months ago
Edited 9 months ago

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)

1 answer

Log in to vote
0
Answered by 9 months ago
Edited 9 months ago

1st

--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)

2nd

--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

0
okay, im gonna play with these scripts, ill let you know what happens 1freshkidz1 9 — 9mo
0
okay for the second, can you explain a little bit more. if you'll like i'll set up team create. its up to you 1freshkidz1 9 — 9mo
0
so make a folder put it in workspace put some string values in there, whenever someone gets a dorm have the script change one of the strings to the players name if they don't already have one Earthkingiv 55 — 9mo
Ad

Answer this question