#server script cant manipulate server storage elements

1 messages · Page 1 of 1 (latest)

carmine delta
#

i have a server sided script that attempts to create a new folder inside ServerStorage, however its not working, i tried printing where its parented to and it says nil

i searched and found a possible solution which is pre-making a folder manually and then cloning it and manipulate according to what i need, didnt worked too

there is not much more i can say, the code is literally this
local sala = Instance.new("Folder", game:GetService("ServerStorage"):FindFirstChild("Salas"))

hollow scaffold
#

because if the parent is saying nil, salas does not exist

tame lintel
#

btw i recommend u doing .Parent on a new line, parent argument is deprecated

#

also doing FindFirstChild is kinda pointless here

carmine delta
#

even suggested by the studio when ur typing

carmine delta
tame lintel
#

tbh i have no idea why this doesnt work, seems fine unless im missing out on something

hollow scaffold
#

same

tame lintel
#

what's the print result of ServerStorage:FindFirstChild("Salas")

rugged gustBOT
#

studio** You are now Level 1! **studio

tame lintel
#

it has to be nil

#

literally nothing else is possible

carmine delta
rugged gustBOT
#

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

carmine delta
#

when ANOTHER function on the same script have an error, the instance.new works properly

tame lintel
#

wtf

carmine delta
#

however if both functions doesnt have any error, the instance doesnt do its job

#

also the print doesnt works

#

the folder is created but theres no printing

tame lintel
#

can u give more detail on ur code

carmine delta
# tame lintel can u give more detail on ur code
CRIARSALA.OnServerEvent:Connect(function(player, sal, jog, par)
    local sala = Instance.new("Folder")
    print("service", game:GetService("ServerStorage").Salas)
    sala.Parent = game:GetService("ServerStorage").Salas
    local sNome = Instance.new("StringValue")
    sNome.Parent = sala
    local sJogs = Instance.new("IntValue")
    sJogs.Parent = sala
    local sPars = Instance.new("IntValue")
    sPars.Parent = sala
    local jogadores = Instance.new("Folder")
    jogadores.Parent = sala
    local host = Instance.new("IntValue")
    host.Parent = sala
    
    sala.Name = player.UserId
    sNome.Name = "sal"
    sJogs.Name = "jog"
    sPars.Name = "par"
    sNome.Value = sal
    sJogs.Value = jog
    sPars.Value = par
    jogadores.Name = "jogadores"
    host.Name = player.UserId
    
    ATUALIZARSALAS:FireAllClients(sala.Name, sNome.Value, sJogs.Value, sPars.Value)
end)

EXCLUIRSALA.OnServerEvent:Connect(function(player)
    local host = tostring(player.UserId)
    local sala = game:GetService("ServerStorage").Salas:FindFirstChild(host)
    sala:Destroy()
    sala = nil
    REMOVERSALA:FireAllClients(host)
end)
#

in the second function

#

if its Salas:WaitForChild

#

it works

#

but i get a error message on console

#

if its FindFirstChild, no error message but nothing works

#

lemme try changing print to warn

carmine delta
tame lintel
#

what is this supposed to do?

#

the last part

carmine delta
#

delete the whole thing created above

tame lintel
#

so what runs and what doesnt in the last function

carmine delta
#

cuz of the findfirstchild

#

if its waitforchild, no error message

tame lintel
#

waitforchild timeouts? or it actually gives it

carmine delta
#

wdym

tame lintel
#

waitforchild has a timeout, if the given timeout parameter or default exceeds, u get a warning in the console

carmine delta
#

no warning on console if its waitforchild

#

everything seems to work as intended

#

however, nothing is created on server storage

tame lintel
#

wth how

carmine delta
#

if its a studio bug, then i have to change my approach on this system

tame lintel
#

nah its not a studio bug

#

its prob a simple name mismatch but i can't see it cause im on my phone

#

are u sure these events are being fired correctly?

rugged gustBOT
#

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

carmine delta
#

i think i know what to do to fix

tame lintel
carmine delta
#

yea i fixed it

tame lintel
#

what was it

carmine delta
#

if its waitforchild, apparently the studio waits for it forever and dont execute anything else

tame lintel
#

it should timeout tho

carmine delta
#

thats why when i put findfirstchild it worked

carmine delta
tame lintel
#

bruh

carmine delta
#
local sala = game:GetService("ServerStorage").Salas:FindFirstChild(host)
    if sala then
        sala:Destroy()
        sala = nil
        REMOVERSALA:FireAllClients(host)
    end
#

by putting this if

#

it now works

tame lintel
#

yea ik if fixes this but still if its even needed then something is kinda wrong

#

cause like

#

if you fire events in the correct order this SHOULD exist unless u have a critical bug but alr ig it works

#

btw

#

instead of doing GetService inline several times just declare a variable ServerStorage

#

more readable

carmine delta
#

yea im aware

rugged gustBOT
#

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

carmine delta
#

thx

tame lintel
#

np

#

also that sala = nil is unnecessary, Destroy by design makes this variable nil, it would get gc

#

just so yk