How do I make two objects which is welded together, to interact with each others

  1. What do you want to achieve? Keep it simple and clear!

So, what I am trying to do is really simple. I am making a game similar to “Waste Of Space” on ROBLOX, which is space engineering game, and you can simply do something like drag solar panel to touch powercell, and it gets powered.

(A IMAGE OF POWERCELL AND SOLAR PANEL CHARGER FOR VISUALIZATION PURPOSES)

  1. What is the issue? Include screenshots / videos if possible!

Like Waste Of Space does, my game also uses drag tool, which welds any unanchored part to other part, making it welded together. I am trying to make a script where I can search through the object A’ (Solar panel)'s children for welds linked to object B (powercell), then if there’s weld, check if it’s named something like “Powercell”,. and make a function replying to that weld connection such as making powercell “charged” from solarpanel. As you can see, that would be really difficult to achieve. Unless you know something I don’t.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I tried everything, really but I can’t figure it out, the script simply just refuse to find any welds in object and do something with it, nor even accessing that weld’s connected part if found… Nothing works. I searched through countless APIs/methods in ROBLOX documentation, and really can’t think of anything.

I really desperately need help with this, and I would greatly appreciate any tip-offs or any kind of help generally, I just hope I can get this solved overnight. Thanks!

edit for clarification: I do NOT know how to make script for checking through all children. I am not THAT good at scripting, and all of my objects in game is one-part model with decals on it, it’s not a multi-part model. I tried my best to understand this but it’s a problem that I simply can’t solve.

  1. First, you need to go through all the parts inside the solar panel in your game. It’s like checking each item inside a box.
  2. For each part, you need to see if it is connected to another part using a weld. Think of it as checking if two objects are stuck together.
  3. If you find a weld, you then need to check if the other part it is connected to is the power cell. It’s like checking if the other object is the power cell you’re looking for.
  4. If the connected part is indeed the power cell, you can perform an action to make it “charged”. This could involve calling a function or setting a property to change its state.

Thanks for your comment, but I already know this. The problem is how to do it? I am not really that good at programming

Is that why you came for scripting support

Perfect! :+1: Ok here try this man
(Custom data related to instances.

set/get attribute)


local solarPanel = game.Workspace.SolarPanel
local powercell = game.Workspace.Powercell

for _, child in ipairs(solarPanel:GetChildren()) do
    if child:IsA("Weld") and child.Part1 == powercell and child.Name == "PowercellWeld" then
        powercell:SetAttribute("Charged", true)
        break
    end
end

OR something like a print to see it work

if child:IsA("Weld") and child.Part1 == powercell and child.Name == "PowercellWeld" then
        -- Perform action when weld meets conditions (e.g., mark Powercell as "charged")
        print("Powercell is charged from Solar Panel!")

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.