Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is my cup tool not showing the actual cup?

So basically I created a cup tool and I added a weld script. When I test the game and put the cup in StarterPack the actual cup container thing is invisible as well as the ring on top of it. Why is this happening? The 2 parts that I can't see when I play are called 'Cup' and 'Ring'. I even went into test mode, went to my character and selected the 2 parts in explorer and it shows it's where it's supposed to be: https://gyazo.com/3fb2718bac5b97f5bd926ff7a3c6f69c

Here is the code inside the weld script:

local prev
local parts = script.Parent:GetChildren()
for i = 1,#parts do
	if ((parts[i].className == "Part") or (parts[i].className == "Handle") or (parts[i].className == "WedgePart") or (parts[i].className == "Seat") or (parts[i].className == "TrussPart") or (parts[i].className == "VehicleSeat") or (parts[i].className == "UnionOperation") or (parts[i].className == "SkateboardPlatform")) then
		if (prev ~= nil) then
			local weld = Instance.new("Weld")
			weld.Part0 = prev
			weld.Part1 = parts[i]
			weld.C0 = prev.CFrame:inverse()
			weld.C1 = parts[i].CFrame:inverse()
			weld.Parent = prev
			parts[i].Anchored = false
		end
		prev = parts[i]
	end
end
wait(3)

Cup Parts: https://gyazo.com/4c260cf33f88c2cedd229f455184b9d1

What the cup is supposed to look like: https://gyazo.com/d964a2420528a3473c9f35fc4ec01d84

What it looks like when I hold it: https://gyazo.com/f8399c109216af24672db62e740154a9

55 comments

0

why are you using free models

0

Sounds to me like it's just taking a while to render? Probably not a script issue.

0

@incapaxian Roblox uses a system which is now derogatorily called free models in which developers can share their creations and allow new developers to create games with minimal code.

0

Unity and Unreal engine use similar systems. The difference being, they call it blueprints.

0

The cup isn't a free model. My friend sent me the script. Also, I highly doubt it's a rendering issue as I held the cup for like a minute and still it didn't do anything.

0

It's not frowned upon in the real world. People do the work then share the work for others to use. As with any similar system, the items, scripts, objects, etc you take may not be of the best quality. At least in Roblox, it's free.

0

Alright. I'll take a look at the script.

0

You said when you select the objects while the tool is equipped, the hit box for those objects is in the correct place?

0

Is the Cup inside of a Part called Handle?

0

Yes.

0

I had to ask

0

Have you tried Unioning the parts instead of welding?

0

Also, can you guys stop arguing about free models. This is supposed to be for helping people not arguing. Yes, the script is a free model but does that really matter?

0

How would I do that, simplealgorithm?

1

No it doesn’t

0

You could actually just use a mesh instead, that way it's perfect everytime

0

Select the amount of parts that should be touching each other, I believe the tool is in the Model section of the banner in Studio, click Union

0

That was my point. Instead of helping he was ridiculing the use of free models which is unecessary.

0

I don't know how to create meshes. That's why I stick to creating things with Roblox parts. Also, yes all the parts that are needed to be unioned are unioned. I thought you meant with the script.

0

I still think it's a render issue. Or the model uses MeshParts or unions that have bugged out or are not opensourced.

0

Yes a mesh is preferred but it’s tough to figure out if you’re new, also have you defined exactly what prev was being nil,

0

Yes a mesh is preferred but it’s tough to figure out if you’re new, also have you defined exactly what prev was being nil?

0

That's the usual problem with stuff like this

0

It doesn’t seem that you’re really checking if the value was nil, after all it’s not even tied to anything, the value only is actually set after the weld

0

I've used this script before on other items and it has worked. I'm not sure what's happening this time though.

0

The script itself looks fine. Aside from poor techniques.

0

ROBLOX Updates the Studio whilst deprecating things and not telling us, it happens a lot, things will break with no provided fix

0

You’ll have to get used to it;)

0

The thing is, I tested out one of my old items and it works perfectly fine. It uses the exact same script.

0

Try setting the welds parent as the first thing, not the last?

0

Didn't work. :/ I know the part is in the right place but the thing is, you just can't see it.

0

Line 7 should set the parent

0

Hmm:/

0

Should I try to rebuild the cup?

0

It’s something to do with the variable prep, I think it’s because you never set prev to anything for the first object, as prev means the second

0

SH is not a site to get help with scripts you did not create.

0

No. Prev is being set to the first object in iteration. No welds are created until after Prev has been set. That's not an issue.

0

Just try moving the prev variable set above the if statement?

0

Oh, right, prev is a Global variable not Local, I’m stupid

0

It's checking if prev is nil. If prev is nil, we skip right over that if statement and set prev so we can run the next iteration.

0

Which if statement?

0

F

0

If prev

0

After it does it's extremely long and complex check to make sure the object being welded is a base part, it checks.

0

But I’m wrong, I know AZDev, I Script too;)

0

if (prev ~= nil) then

0

You may script. But it's clear you don't understand the code.

0

Now it completely doesn't work.

0

I've tried a bunch of different weld scripts but it still doesn't show those two parts. I might just need to rebuild the cup.

0

@TypicallyPacific Is it my script? If not, give mine a go. If it doesn't work, I'll get it fixed.

0

Your script isn't working either. I feel like it's a glitch with Roblox studio when I built it. No weld script is working. I may try to rebuild the cup and add the weld script back.

0

I just tried to separate the cup union and it disappeared.

0

It was a corrupt union.

0

I am not so great with welds, I could do it before, not anymore;) Looks like I have something to learn

0

I had to rebuild it. Sorry for making you try to fix the script :/

1 answer

function Weld(p)
	
	local Parts = p:GetChildren()
	local Prev

	for i, v in pairs(Parts)
		if v:IsA("BasePart") then
			if Prev then
				local Weld = Instance.new("Weld")
				Weld.Name = Prev.Name .. "_" .. v.Name
				Weld.Part0 = Prev
				Weld.Part1 = v
				Weld.C0 = Weld.Part0.CFrame:inverse()
				Weld.C1 = Weld.Part1.CFrame:inverse()
				Weld.Parent = Prev
			end
			Prev = v
		end
	end

	-- Unanchor parts
	for i, v in pairs(Parts) do
		if v:IsA("BasePart") or v:IsA("MeshPart") then
			v.Anchored = false
		end
	end
end

If the code is the problem, this should make a difference. I wrote it up in an external ide without code completion. If it doesn't work I'll test it in studio.

Fixed. MeshPart apparently inherits class BasePart. Removed redundant check.

2 comments

0

Why are you checking if v is a mesh part on line 7, checking if it's a base part will suffice. MeahPart inherits BasePart making the second check completely redundant

0

It didn't used to. If it does, then it's simple enough to remove it.

This discussion is preserved as it was. New answers, comments, and votes are closed.