Script doesnt work, but theres no error 4

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    A “welding” part that welds to other parts of specific names.
  2. What is the issue? Include screenshots / videos if possible!
    It doesnt work, but theres no errors.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Nothing, no.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
script.Parent.Touched:Connect(function(hit)
	if hit.Name=="2x1x2" or "3x3x3 Ball" or "2x2x2" or "4x1x2" then
		local w=Instance.new("WeldConstraint")
		w.Part0=script.Parent
		w.Part1=hit
	end
	if hit.Parent:FindFirstChild("Humanoid") then
		return
	end
end)

The script is above.

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Is the weld Enabled? Have a look when you test it.

Also, put print(hit) after the first line to see what is actually being touched.

The weld SCRIPT or the constraint created?

You need to check each condition separately like this:

if hit.Name == "2x1x2" or hit.Name == "3x3x3 Ball" or hit.Name == "2x2x2" or hit.Name == "4x1x2" then

Didnt work, i used my character to fling them around as a test and they didnt weld together.

He definitely means the weld constraint. Also, try this script.

script.Parent.Touched:Connect(function(hit)
	if hit.Name=="2x1x2" or "3x3x3 Ball" or "2x2x2" or "4x1x2" then
		local w=Instance.new("WeldConstraint")
        w.Enabled=true
		w.Part0=script.Parent
		w.Part1=hit
        w.Parent=script.Parent
	end
	if hit.Parent:FindFirstChild("Humanoid") then
		return
	end
end)
1 Like

Small issue, it seems to be gluing itself to a part i used to spawn the bricks, it is welded to the head and the name is Place. I tried to use more conditions but nothing worked.

1 Like

Ok so I think we could help you more if you gave us more info on what you are trying to accomplish. Thanks!

1 Like

A game where you have about 5 bricks to build things, it uses mainly parts with scripts to work.

1 Like

Im almost finalizing the building system but at this part its just faltering.

1 Like

Alright soooo, let me test some things and get back to you. Also, it would also help to know how the building setup works! :slight_smile:

I can give you a .rbxl for you to see how it works.

1 Like

Alright thanks! I think I can work with that.

Heres the file:
buildersandbricks!.rbxl (104.5 KB)

1 Like

This should be the fix, if this doesn’t work then I have no idea

script.Parent.Touched:Connect(function(hit)

	if hit.Name == "2x1x2" or hit.Name == "3x3x3 Ball" or hit.Name == "2x2x2" or hit.Name == "4x1x2" then

		if hit.Parent:FindFirstChild("Humanoid") then
			return
		end
		
		local w = Instance.new("WeldConstraint")
		w.Enabled = true
		w.Part0 = script.Parent
		w.Part1 = hit
		w.Parent = script.Parent
	end
end)

It worked! Thank you for helping!

1 Like

no problem, happy I could help. :grin:

I just figured out the issue, but I see its already resolved! :person_shrugging: Glad you have a resolution! :smiley: By the way, your game here is really cool! :+1:

Good job, @PowFPS1 by the way!

1 Like

Thanks for the compliment! If you want, you can keep talking to me through the Roblox website on the game!