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)

3 comments

0

you need to give more than your script i dont understand a thing or two at all

0

Can you explain your question? Parts don't have text anywhere on them, do you mean remove text from a gui on the part?

0

just a idea but maybe try make the script understand if the player who owned the locker left?