#cloning template but doesnt want to?

1 messages · Page 1 of 1 (latest)

surreal lava
#
local function CreateRoom(map, gamemode, timeofday)
    local template = script:FindFirstChild("ServerTemplate")
    if not template then
        warn("ServerTemplate not found")
        return
    end

    local clone = template:Clone()
    clone.Name = map.."_"..gamemode

    if clone:FindFirstChild("Map") then
        clone.Map.Text = map
    end
    if clone:FindFirstChild("Gamemode") then
        clone.Gamemode.Text = gamemode
    end
    if clone:FindFirstChild("TimeOfDay") then
        clone.TimeOfDay.Text = timeofday
    end

    clone.Parent = ServerListScroll
end```

trying to make a template be cloned but it just doesnt want to. (yes it kind of looks like AI i think)
#

and yes everything is defined

#

but problem right now is that it just doesnt want to clone <:(

gritty grail
#

doesn't want to clone... as in clone.Name = map.."_"..gamemode returns an error due to clone being nil?

ripe tendon
#

no cos the function returns

gritty grail
#

returns early?

ripe tendon
#

its either throwing an error or its returning

#

if not template then
warn("ServerTemplate not found")
return
end

#

^^^^^^^

gritty grail
#

there's a huge difference between erroring and returning

ripe tendon
#

so if hes getting the warning

#

its returning

#

and not cloning

ripe tendon
#

u are dumb

surreal lava
#

it doesnt even output anything in console

#

literally

gritty grail
#

he never said it warned him

ripe tendon
#

what is template defined as, I'm assuming its a frame of sorts

surreal lava
#

yes

surreal lava
#

and inside is stored a button and textlabels

ripe tendon
#

you got a UIListLayout in there?

surreal lava
#

no

ripe tendon
#

in the scrolling frame

#

so how is it structuring the list

surreal lava
#

theres no scrolling frame

ripe tendon
#

ServerListScroll

#

^

surreal lava
#

lemme show u

ripe tendon
#

i assumed it was a scrolling frame

gritty grail
surreal lava
ripe tendon
#

yep

gritty grail
#

bro is just hugely prejudiced rn

ripe tendon
#

ur usin a lot of findfirstchilds

#

tbh

#

for already existing instances you know are gonna be there

#

you should probably jus use a waitforchild once at the top somewhere and the rest of the instances shouldnt have a problem loading before then

#

but

surreal lava
#

this is the original script

local function CreateRoom(map, gamemode, timeofday)
    local template = script.ServerTemplate
    local clone = template:Clone()
    
    clone.Name = map.."_"..gamemode
    --clone.Hoster.Text = player
    clone.Map.Text = map
    clone.Gamemode.Text = gamemode
    clone.TimeOfDay.Text = timeofday
    clone.Parent = ServerListScroll
end```
ripe tendon
#

thats not the error

#

so can you jus do me a favour

surreal lava
#

o

ripe tendon
#

and define the arg types

#

map : string, gamemode: string, timeofday : number etc etc

#

so i know what information you're passing

#

and for this "list", it seems to have nowhere to actually go bro ngl

#

if it isnt a scrolling frame where is it going?

surreal lava
#

its no list tho

ripe tendon
#

and is it even visible

surreal lava
#

yes

#

it is

#

i double checked

ripe tendon
#

can u show me the UI

#

on the screen

#

i could probably rewrite this in 2 mins bro ngl

surreal lava
#

gladly

surreal lava
#

so i dont cause in the future

ripe tendon
#

is that the UI

#

the whole thing

surreal lava
#

yes

#

entire

#

inside a ui

#

o wait im dmb

ripe tendon
#

add a UIListLayout

#

and yes it does have a scrolling frame

surreal lava
#

i legit said ServerListScroll wasnt a scrolling frame

ripe tendon
#

😭

surreal lava
#

mb

surreal lava
#

is that ok?

ripe tendon
#

yeah

surreal lava
#

alr

ripe tendon
#

thing is it would structure it

#

where are u calling this function

#

is it the event you sent in scripting before?

surreal lava
#

yes

ripe tendon
#

okay can u do me a favour

surreal lava
#

its calling in a sc ript

ripe tendon
#

add a print statement

surreal lava
#

?

ripe tendon
#

under the event

surreal lava
#

yes

ripe tendon
#

and check if it prints

#

once it receives it

#

and also show me the event sequence

#

cos there might be something wrong there

surreal lava
#
local function onGamemodeTeleportRequested(player, roomName, mapName, gamemodeName, timeofDayName)
    print(("[MapTeleportHandler] Received teleport request from player %s for Map: '%s', Gamemode: '%s, Time of Day: %s'"):format(player.Name, tostring(mapName), tostring(gamemodeName), tostring(timeofDayName)))
    print(roomName)
    
    
    if not player.Character then
        warn(("[MapTeleportHandler] Player %s (initiator) has no character. Teleport aborted."):format(player.Name))
        return
    end

    local validPlayersToTeleport = {player}
    local playerNamesToTeleport = {player.Name}

    local targetPlaceId = nil
    if mapName and gamemodeName and timeofDayName and placeTeleportConfig[mapName] and placeTeleportConfig[mapName][gamemodeName] then
        targetPlaceId = placeTeleportConfig[mapName][gamemodeName][timeofDayName]
    end
    
    ServerSystem:FireClient(player, "CreateRoom", mapName, gamemodeName, timeofDayName)

    if not targetPlaceId then
        if mapName and placeTeleportConfig[mapName] then
            warn(("[MapTeleportHandler] Map '%s' found, but Gamemode '%s' or Time of Day '%s' not configured for this map for player %s."):format(tostring(mapName), tostring(gamemodeName), tostring(timeofDayName), player.Name))
        elseif mapName then
            warn(("[MapTeleportHandler] Map '%s' not found in configuration for player %s."):format(tostring(mapName), player.Name))
        else
            warn(("[MapTeleportHandler] Invalid mapName or gamemodeName received. Map: '%s', Gamemode: '%s', Time of Day: '%s'. Teleport aborted."):format(tostring(mapName), tostring(gamemodeName), tostring(timeofDayName)))
        end
        return
    end

    local success, errorMessage = pcall(function()
        TeleportService:Teleport(targetPlaceId, player)
    end)

    if not success then
        warn(("[MapTeleportHandler] Failed to teleport player %s to PlaceId %s. Error: %s"):format(player.Name, tostring(targetPlaceId), errorMessage))
    end
end```
#

this is where its calling it from

ripe tendon
#

holly

surreal lava
#

its in a script in SSS

#

this

ripe tendon
#

.OnClientEvent??

#

can u show me that plz

surreal lava
#
ServerSystem.OnClientEvent:Connect(function(player, actionType, ...)
    if actionType == "CreateRoom" then
        CreateRoom(...)
    end
end)```
#

here u go

ripe tendon
#

take player

#

off client event

#

it automatically receives to localplayer

surreal lava
#

o

ripe tendon
#

yeah lol dw its a common mistake

surreal lava
#

the moment u said player

#

i instantly realized

ripe tendon
#

LOL dw bro

#

it should work now

surreal lava
#

i dont know much about firing client tbh

#

alr

#

lemme try

#

yessir

ripe tendon
#

noice

surreal lava
#

it did clone

#

it says gamemode and everything

#

thx

#

so much

ripe tendon
#

glad i could be of some help