#making a StringValue change when a player leaves the game

61 messages · Page 1 of 1 (latest)

late raft
#

just in case
Buying apartment script(no errors in here tho)

local ownerText = script.Parent.Parent.Parent.OwnerSign.BulletLabel.TextLabel

local AMOUNT = 200


script.Parent.MouseClick:Connect(function(plr)
    if not game.Workspace:FindFirstChild("Home"..plr.Name) then
        script.Parent.Parent.Label.Enabled = true
        script.Parent.MaxActivationDistance = 10
        if game.Players:findFirstChild(plr.Name) ~= nil then
            if plr.leaderstats.Cash.Value >= AMOUNT then
                plr.leaderstats.Cash.Value -= AMOUNT
            local b = script.Parent.Parent:Clone()
            b.Parent = game.Lighting
            b.Name = "Home"..plr.Name
            wait()
            script.Parent.Parent.Parent.OwnerName.Value = plr.Name
            ownerText.Text = plr.Name
                script.Parent.Parent.Label.Enabled = false
                script.Parent.MaxActivationDistance = 0
                
            end
        end
    end
end)
warped otter
#

Prob because of the player instance isn't nill so it failed the if check and didn't change the text

late raft
#

Just remove that

warped otter
#

Yup, I dont see any reason to have that

late raft
#

@warped otter it don’t work

#

The players name stays the same when they leave

#

or the value doesnt change

warped otter
#

You are using 2 player to test it right? Or did you test it by entering game and leaving game (in studio)

late raft
#

2 player

#

in roblox

warped otter
#

Should work

twin nimbus
#

hey some help in mine when you can?

#

also

warped otter
#

Or is the line where it check if the value is the same with the player name failed

twin nimbus
#

you can run game.players.playerleave:connect(function)

late raft
twin nimbus
#

@late raft

#

yeah

#

game.Players.PlayerRemoving:Connect(function(plr)

late raft
twin nimbus
#

were you doing it right

#

it has to be serverscript

late raft
#

its under the string value

#

as a script

twin nimbus
#

where the string val

late raft
twin nimbus
#
game.Players.PlayerRemoving:Connect(function(plr)
    if script.Parent.Value == plr.Name then
        script.Parent.Value = "Whatever u want lil brah"
    end
end)
late raft
#

already have that

#
game.Players.PlayerRemoving:Connect(function(plr)
    if script.Parent.Value == plr.Name then
            script.Parent.Value = "Vacant"
    end
end)
twin nimbus
#

put a print under the first line

leaden snowBOT
#

studio** You are now Level 12! **studio

twin nimbus
#

print("playerremoved")

#

then

late raft
#

alright

twin nimbus
#

print("plr name good")

#

lmk if botjh print

late raft
#

or above it

twin nimbus
#

under

late raft
#

ight

twin nimbus
#

first obe goes under the first line

late raft
#

Weird lemme re try in a normal game now

twin nimbus
#

ight

late raft
#

It shows it changed the value but it stays the same

#

Wait I might add a while wait() do
Value of string value

twin nimbus
#

awitt lemme acutally look at the script rq

#

also next time

#

its better

#

to have a main script

#

inside\

#

of the model/folder holding all the buildings

#

and run loops through them

#

so you dont have to put scripst in every single one

#

bro

#

u put findFirstChild

#

instead of FindFirstChild

#

idk if that did anything tho