#Does anyone know why this isn't working?

1 messages · Page 1 of 1 (latest)

untold wave
#

SOLVED!

FIX
The data was being reverted due to the fact that when I changed the data, it was detected with the Heartbeat function and reverted back right before the server truly closed.

TIP
When trying to test :BindToClose() in the main game, try using the Migrate feature to test if it works. When migrating, the game will freeze for a second when it's already closed, therefore showing what is happening while the server is closing.

verbal lakeBOT
#

studio** You are now Level 3! **studio

strange inlet
verbal lakeBOT
#

studio** You are now Level 9! **studio

untold wave
tired badge
strange inlet
strange inlet
untold wave
#

called after the variables are declared and before any functions are done

muted sail
#

how'd you test it

strange inlet
untold wave
untold wave
muted sail
#

bindtoclose runs when everyone leaves

untold wave
#

yes

#

Some context I'd like to add is it stopped working after I got kicked for being idle for 20 mins

muted sail
#

when u normally leave it works?

untold wave
#

yes

muted sail
#

you could just do Players.PlayerRemoving if #Players:GetPlayers() == 1 then blah blah

strange inlet
#

ur just trying to get the idle kick to work?

muted sail
untold wave
#

since it stops working entirely and forever

#

unless i reset the data

strange inlet
#

try what kasper said

muted sail
#

I found the issue

#

when the player is kicked

#

it doesnt count as

#

game being closed

untold wave
#

hold on

#

but there's something called "CloseReason"

#

indicating that it can detect different ways of shutting down

muted sail
#

wat

#

welp clearly not if its not working with Kicked

untold wave
#

anyways, if it didn't count if someone was kicked, that's a major issue

muted sail
#

yes

untold wave
#

i'm sure it would be fixed by now

#

so I don't think the Idle = not countedc

muted sail
#

perhaps its intentional

#

wait ill see

untold wave
#

and why?

#

weird

#

for some reason I called an event and it's not working either

#

but the script is continuing

silver hound
verbal lakeBOT
#

studio** You are now Level 4! **studio

silver hound
#

hence once the server shuts down, unless you're saving something to a datastore, it's gonna revert back

untold wave
#

hm?

silver hound
#

if you have money = 50 and inside bind to close function you put money == 100

untold wave
#

oh yeah im using profilestore

silver hound
#

money will still be 50

untold wave
#

ik

silver hound
#

never used profilestore

untold wave
#

oh

silver hound
#

just add an else inside

#

else print("not equal")

muted sail
silver hound
#

maybe your logic is wrong

untold wave
muted sail
#

It's a studio thing, it works normally in roblox

untold wave
#

no i tested it in roblox

muted sail
#

I kicked myself and it ran the function

untold wave
#

well yeah ofc that'd work lol

#

and i didnt lie

muted sail
#

it does in roblox

untold wave
#

i was saying the opposite side of the claim

untold wave
untold wave
#

i said that

silver hound
#

well all i'm seeing is = 0

#

you're not calling the save function or whatever profile store has

#

it's just editing a variable

muted sail
#

maybe its sm else

untold wave
#

oh yeah something else random is just fsr my game.PlayerAdded didn't work so I had to loop through the players when the script started. Roblox is dumb :/

untold wave
#

no i saw the ID

#

it prints the JOB id

muted sail
#

what if sm else is the problem like data.Data.MainServer is not game.JobId

silver hound
muted sail
#

hmm

silver hound
#

roblox isn't dumb

untold wave
silver hound
#

just poor code

untold wave
#

hey i didnt know profilestore yields before grabbing the data

muted sail
#

like a couple seconds

#

yea

silver hound
untold wave
#

DataStore service is worse

#

with handling data

silver hound
#

right and what do you think profilestore uses?

#

it's the same thing

#

just they added a layer of security and good code for handling data

untold wave
silver hound
#

i've read it

#

that's all i need

#

never had issues saving data with my own way

untold wave
#

it's a better practice to use profilestore

silver hound
#

i don't know who said that but ok i guess

muted sail
untold wave
muted sail
#

profilestore has its own issue

untold wave
#

like what

muted sail
#

we had this debate in scripting

#

wait

#

ill send

#

yea I cant find it

#

it was months ago

untold wave
#

the thing is working at all now 😔

#

bindtoClose isn't running

silver hound
#

it's just your if statement is useless

untold wave
untold wave
#

the if statement is checking if that server is the main server

#

if so, it will set the main server to the default value-in which will be set to the next server/an existing server

#

i think i figured out the problem

#

welp ik the problem

#

the thing is yielding for too long

#

man it was working before but then randomly stopped working. I made no changes :/

#

FIXED YAYAYYYYAYYAYAYAYAYAYAY

#

ill edit the message to the fix