Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is my cup tool not showing the actual cup?

Asked by 5 years ago

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

0
why are you using free models User#24403 69 — 5y
0
Sounds to me like it's just taking a while to render? Probably not a script issue. AZDev 590 — 5y
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. AZDev 590 — 5y
0
Unity and Unreal engine use similar systems. The difference being, they call it blueprints. AZDev 590 — 5y
View all comments (51 more)
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. TypicallyPacific 61 — 5y
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. AZDev 590 — 5y
0
Alright. I'll take a look at the script. AZDev 590 — 5y
0
You said when you select the objects while the tool is equipped, the hit box for those objects is in the correct place? AZDev 590 — 5y
0
Is the Cup inside of a Part called Handle? Ziffixture 6913 — 5y
0
Yes. TypicallyPacific 61 — 5y
0
I had to ask Ziffixture 6913 — 5y
0
Have you tried Unioning the parts instead of welding? Ziffixture 6913 — 5y
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? TypicallyPacific 61 — 5y
0
How would I do that, simplealgorithm? TypicallyPacific 61 — 5y
1
No it doesn’t Ziffixture 6913 — 5y
0
You could actually just use a mesh instead, that way it's perfect everytime SteamG00B 1633 — 5y
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 Ziffixture 6913 — 5y
0
That was my point. Instead of helping he was ridiculing the use of free models which is unecessary. AZDev 590 — 5y
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. TypicallyPacific 61 — 5y
0
I still think it's a render issue. Or the model uses MeshParts or unions that have bugged out or are not opensourced. AZDev 590 — 5y
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? Ziffixture 6913 — 5y
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, Ziffixture 6913 — 5y
0
That's the usual problem with stuff like this SteamG00B 1633 — 5y
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 Ziffixture 6913 — 5y
0
I've used this script before on other items and it has worked. I'm not sure what's happening this time though. TypicallyPacific 61 — 5y
0
The script itself looks fine. Aside from poor techniques. AZDev 590 — 5y
0
ROBLOX Updates the Studio whilst deprecating things and not telling us, it happens a lot, things will break with no provided fix Ziffixture 6913 — 5y
0
You’ll have to get used to it;) Ziffixture 6913 — 5y
0
The thing is, I tested out one of my old items and it works perfectly fine. It uses the exact same script. TypicallyPacific 61 — 5y
0
Try setting the welds parent as the first thing, not the last? Ziffixture 6913 — 5y
0
Didn't work. :/ I know the part is in the right place but the thing is, you just can't see it. TypicallyPacific 61 — 5y
0
Line 7 should set the parent Ziffixture 6913 — 5y
0
Hmm:/ Ziffixture 6913 — 5y
0
Should I try to rebuild the cup? TypicallyPacific 61 — 5y
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 Ziffixture 6913 — 5y
0
SH is not a site to get help with scripts you did not create. xPolarium 1388 — 5y
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. AZDev 590 — 5y
0
Just try moving the prev variable set above the if statement? Ziffixture 6913 — 5y
0
Oh, right, prev is a Global variable not Local, I’m stupid Ziffixture 6913 — 5y
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. AZDev 590 — 5y
0
Which if statement? TypicallyPacific 61 — 5y
0
F Ziffixture 6913 — 5y
0
If prev Ziffixture 6913 — 5y
0
After it does it's extremely long and complex check to make sure the object being welded is a base part, it checks. AZDev 590 — 5y
0
But I’m wrong, I know AZDev, I Script too;) Ziffixture 6913 — 5y
0
if (prev ~= nil) then AZDev 590 — 5y
0
You may script. But it's clear you don't understand the code. AZDev 590 — 5y
0
Now it completely doesn't work. TypicallyPacific 61 — 5y
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. TypicallyPacific 61 — 5y
0
@TypicallyPacific Is it my script? If not, give mine a go. If it doesn't work, I'll get it fixed. AZDev 590 — 5y
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. TypicallyPacific 61 — 5y
0
I just tried to separate the cup union and it disappeared. TypicallyPacific 61 — 5y
0
It was a corrupt union. AZDev 590 — 5y
0
I am not so great with welds, I could do it before, not anymore;) Looks like I have something to learn Ziffixture 6913 — 5y
0
I had to rebuild it. Sorry for making you try to fix the script :/ TypicallyPacific 61 — 5y

1 answer

Log in to vote
0
Answered by
AZDev 590 Moderation Voter
5 years ago
Edited 5 years ago
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.

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 User#24403 69 — 5y
0
It didn't used to. If it does, then it's simple enough to remove it. AZDev 590 — 5y
Ad

Answer this question