function onTouched(player)
if lockerowned.Value == false then
print(player)
lockerowned = true
local lockertext = script.Parent.LockerText
local locker= Instance.new("BoolValue", player)
locker.Name = "owningLocker"
locker.Value = true
local lockername= Instance.new("StringValue", player)
lockername.Name = "lockername"
lockername.Value = script.Parent.Parent.Name
script.Parent.LockerText.ownedBy.Value = player.Name.." ''s Locker"
lockertext.Text = "Locker owned by: "..lockername[math.random(1,#names)]
else
print("Locker already owned by
script.Parent.LockerText.ownedBy.Value)
end
end
script.Parent.Touched:Connect(onTouched)
game.Players.PlayerRemoving:Connect(function(plr)
local locker = plr:WaitForChild("owningLocker")
local lockername = plr.lockername.Value
local lock = game.Workspace:FindFirstChild(lockername)
if locker.Value == true then
print(plr.Name.." left")
lock.LName.LockerText.LO.Text = nil
lock.LName.lockerowned.Value = false
lock.LName.ownedBy.Value = nil
end
end)
COMMUNITY QUESTION
This is supposed to delete the text off of a part when the player leaves. Why doesn't it work?
0 answers
No public answers were preserved for this question.
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
you need to give more than your script i dont understand a thing or two at all
Can you explain your question? Parts don't have text anywhere on them, do you mean remove text from a gui on the part?
just a idea but maybe try make the script understand if the player who owned the locker left?