#Need a little help with a datastore sort of issue.

119 messages · Page 1 of 1 (latest)

torn dome
#
  1. don't stack waitforchilds for no reason. it exists. and you'll only usually ever need one for the parent
  2. does it have time to get the profile
radiant canyon
#

@torn dome i fixed it my self, and also it was cause of what u said, there wasnt enough time

#

so i just did a repeat task.wait() until the profile loads

torn dome
radiant canyon
#

?

#

i dont see a problem withit

torn dome
#

yeahhh not really

#

you could do a signal inside datamanager when the player is loaded

radiant canyon
#

how would i do that?

torn dome
radiant canyon
#

i mean im doing this for a commision lol, wouldnt really look good to have someone elses code inside of it 😭

torn dome
#

it's... a library? and that's completely normal to use

#

it looks worse you're asking for help than using a simple library

#

esp one that isnt implemented by roblox themself

radiant canyon
urban hedgeBOT
#

studio** You are now Level 2! **studio

torn dome
#

ppl better than u and me use libraries all the time

radiant canyon
#

so

torn dome
#

yeah

#

signals like

radiant canyon
#

does this go in a module script?

torn dome
#

just a recreation of bindableevents but for scripts yk

#

yep

radiant canyon
#

alr

torn dome
#

name it Signal
call :Fire() somewhere with whatever arguments
and then :Connect to the instance somewhere

#

it works like a charm

#

usually i do this in the same module

radiant canyon
torn dome
#

yk bindable events?

#

Just :Fire() and :Connect() right?

radiant canyon
#

yeah

torn dome
#

:Fire() basically calls all the connects

#

yeha

#

it's that but u dont need an instance

#

u get what i mean

#

no bindable events

#

good for events in modulescripts

radiant canyon
#

So instead of repeat task.wait() i would do what though

#

😭

#

ur losing me

torn dome
#

your datamanager is a module

#

put at the top somewhere DataManager.PlayerLoaded = Signal.new() (where Signal is a reference to the signal modulescript)

torn dome
#

then when the players loaded, do DataManager.PlayerLoaded:Fire(args)

#

then at the top of your script, instead of repeat do DataManager.PlayerLoaded:Wait()

#

where args is like. the player or whatever

#

doesnt really matter unless u plan to do an event when a player's loaded

torn dome
#

but when you do :Wait() it returns the arguments passed anyway

#

so it would be the same as getting the player

#

and that's useful info

radiant canyon
#

like this?

#

😭

torn dome
radiant canyon
#

my whole save system isnt working anymore 😭

torn dome
#

exactly like that

#

ohh?

#

perhaps put it inside the profile ~= nil

#

that may fix it

#

put where ur leaderstats create is

#

like after it

radiant canyon
#

nope

#

😭

torn dome
#

that should do that tho 😭

radiant canyon
#

its not printing

torn dome
#

it just fires an event

radiant canyon
#

like anything

torn dome
#

ohhhh

#

you're checking after

radiant canyon
#

and its not saving

torn dome
#

do profile = dataManager.Profiles[plr] or dataLoader.PlayerLoaded:Wait()

radiant canyon
#

alright

#

nope

#

still doesnt work

torn dome
#

and then you can put the :Fire() args the profile

#

when does it not print

radiant canyon
torn dome
#

remove the wait in the other script

#

doubt that'll do anything

radiant canyon
torn dome
radiant canyon
#

so just dataManager.PlayerLoaded?

#

now its erroring saying attempt to index nil with 'team' on line 27

#

wait actually

#

let me change the key to my datastore

torn dome
torn dome
#

u get what i mean

radiant canyon
torn dome
#

at the :Fire()

radiant canyon
#

wait

urban hedgeBOT
#

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

radiant canyon
#

actually

#

i think i do

torn dome
#

of PlayerLoaded do :Fire(profile)

#

bc then :Wait() returns profile when its retrieved

radiant canyon
#

yeah i did

#

okay

#

yeah it works now

#

also a question

#
local Players = game:GetService("Players")
local SSS = game:GetService("ServerScriptService")
local dataManager = require(SSS:WaitForChild("Modules"):WaitForChild("DataManager"))

local function playerChatted(player, message)
    print(player.Name .. " said: " .. message) 
    local splitMessage = string.split(message, " ")
    
    if splitMessage[1] == '/wipe' then
        local player = Players:FindFirstChild(splitMessage[2])
        if not player then return end
        local profile = dataManager.Profiles[player]
        if not profile then return end
        
        profile.Data.Team = nil
        player.leaderstats.Team.Value = "Neutral"
        player.Team = nil
    end
end

local function playerAdded(player)
    player.Chatted:Connect(function(message)
        playerChatted(player, message)
    end)
end

Players.PlayerAdded:Connect(playerAdded)

is there a better way to get the player messages then this 😭

torn dome
#

just put the commands in a modulescript mayhaps

#

function Execute would be what it does, then the name is the command name

radiant canyon
#

😭

torn dome
#

i wouldnt do displays ever

radiant canyon
#

alright