#Baby data module not working properly(data given through remote event when picked up, read below)

1 messages · Page 1 of 1 (latest)

slow pecan
#

As I said, the baby module is given through a remote event to this local script when triggered for the first time,however, I want it to just display when u equip the baby tool, currently only works on the first equip and after that it just displays whenever I add a new baby to my backpack. (through a proximity prompt to pick it up, the one responsible for giving the baby module) I'll probably just have to rewrite all this 😔

digital kindle
#

Pls no txt file im on mobile snd i cant read it

slow pecan
#

Sorry it was too long 😦 I can send a pic

#

I'll just try splitting it

#
local function delOld(GUI)
    for i, v in pairs(GUI:GetChildren()) do
        if v:IsA("TextButton") then
            v:Destroy()
        end
    end
end
emptyLabel.Visible=false

local function equipped()
    delOld(mainGUI)
    if #bp:GetChildren() == 0 then
        emptyLabel.Visible = true
    else
        emptyLabel.Visible = false
    end
    for index, tool in pairs(bp:GetChildren()) do
        if tool:IsA("Tool") then
            local button = Instance.new("TextButton")
            button.Text = tool.Name
            button.Parent = mainGUI
            button.ZIndex = 3

            tool.Equipped:Connect(function()
                    equipSlot = index
                    instruction.Text = "Equipped: " .. tool.Name
                    ReplicatedStorage.babyData.OnClientEvent:Connect(function(babyData)
                        print("Received baby data:")
                    canProceed = true
                        delOld(babyDataDisplay)
                        for key, value in pairs(babyData) do
                            local label = Instance.new('TextLabel')
                            label.Text = tostring(value)
                            if key == 'SkinColor' then
                                label.Text = value.Name
                            end
                            label.Parent = babyDataDisplay
                            label.Visible = true
                            label.ZIndex = 3
                            end
                    end)
            end)

            tool.Unequipped:Connect(function()
                delOld(babyDataDisplay)
            
                if equipSlot == index then
                    equipSlot = 0
                    instruction.Text = 'Hold the baby you want to sell'
                    canProceed = false
                end
            end)
        end
    end
end

bp.ChildAdded:Connect(function()
    equipped()
end)
bp.ChildRemoved:Connect(function()
    equipped()
end)

equipped()```
#

nvm it fit

slow pecan
digital kindle
#

Il try my best brorito

slow pecan
#

horray

#

good luck

digital kindle
#

Hold on

#

So to clarify, the issue is that it works once? @slow pecan

#

But then its stuck?

slow pecan
#

It works as intended once (creates the labels when the baby tool is equipped,removes when unequipped) but on the second try it wont let u equip it back when unequipped and it automatically makes the labels when you trigger the proximity prompt instead of equipping the baby tool

#

i can send a vid

digital kindle
#

Be honest tho, did you use ai for this? Il still try to fix it for you dw

slow pecan
#

hell no

digital kindle
digital kindle
# slow pecan hell no

Then why were you so formal with the names ;-; like 90% of devs dont use names this well

slow pecan
#

i use cgpt for debugging but almost always makes stuff worse and I never copy the scripts, especially when I dont understand them, on this one eg I only needed help with the module cause its my first time working with modules but its not even 1/10 of the script and I made sure to understand it and not just copy it, I dont recall what u mean by the names tho cause Im really shit at managing scripts and did not use AI for anything else

#

anyways sorry 4 yapping ill send the recording

digital kindle
slow pecan
#

yo hold up dude my entire script just broke for some reason probably when I was cleaning up the script to send it here...

#

nvm i just left lua at the start

digital kindle
#

I can wait a bit dw

slow pecan
#

sorry for the shit gui lol im only focusing on getting ts to work atp

#

yh wont even unequip now nor equip the others

#

might just be the del old not working in this case

#

anyways uh its fucked

digital kindle
#

So you dont want it to dissappear when your holding it?

slow pecan
#

No I want it to I'm talking about the frame on the right

#

With the labels

digital kindle
#

Oh ok 1 sec

#

Oh yh it does not change

slow pecan
#

Yup, before it would just change but only when u triggered the proximity prompt after the first try and have problems unequipping but now it's completely broken

digital kindle
#

You know you can add prints to pieces of code to see if it reads it

#

Okay so

slow pecan
#

yeah mb gng

digital kindle
#

Replace textbutton with textlabel at the top

slow pecan
#

Shit I just noticed aha

digital kindle
#

Xd

slow pecan
#

Probably won't solve it still but that's why it wouldn't equip

digital kindle
#

It might

#

At least it will delete the old data

slow pecan
#

I doubt it , it was the same thing before but instead of a delete function I did it manually inside

#

Yuh

digital kindle
#

Hmm i hate doing stuff manually

#

If i can code it i can

#

Uhh

#

Mode it

#

And does it break again or?

slow pecan
#

let me show u how it works now

digital kindle
#

Thx

slow pecan
#

its as i described in the start hold up

digital kindle
#

The vid helped a lot

slow pecan
#

wont equip back on 2nd try and labels get created when proximity prompt is triggered instead of when equipped

#

and that just leads to a lot other problems eg the unequipping is now choppy ah although it doesnt work anyway

digital kindle
#

Alr so heres how to fix youre code: instead of deleting it and all that other stuff you do: make a folder indide the baby model with all the edited values

slow pecan
#

yes thats what i was thinking about doing originally

digital kindle
#

Then name every gui the exact same as every value

slow pecan
#

but some people told me to use tables

#

and classes

digital kindle
#

Run a for loop and do datafolder:findfirstchild(v.name)

slow pecan
#

so i should ditch the module script?

digital kindle
#

And then v.text = datafolded:findfirstchild(v.name)

#

Orv.value

#

For now yeah but when you have more experience come back to modules

slow pecan
#

yh this is like my first time actually using them

digital kindle
#

Modules are hard to understand and all they really do is make your script look nicer

slow pecan
#

also OOP i learnt it yesterday

#

and i had to use classes to make this so uh

digital kindle
slow pecan
#

dude i have no idea I just learnt about making classes and metatables

#

im such a nub

#

👲

#

nub

#

noop

digital kindle
#

Im gonna learn oop rn 1 min

slow pecan
#

It's low-key not as hard as I thought it was it's really simple

digital kindle
#

Alr i learned it

#

Lowkey dawg it aint that hard

#

Cant see a lot of situations where id apply this

slow pecan
#

@digital kindle thank u vroski

digital kindle
#

Nice! Gl with your game! And if u want some fun idea (no pressure) u can add that bird that delivers babys as dropper

slow pecan
#

I actually thought of that but I'm not sure how I'd make it😂😓😓

#

Either way I'm focusing on functionality atm, I think this has potential ngl

digital kindle
#

Well gl with your game