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

Can't seem to get parts to weld together ?

Asked by
Gunt_r 31
4 years ago

Hi, everytime i generate a part with this script, it doesnt weld that piece to any other object.

The primary focus of this code is the elseif statement. That's where all the welding happens.

Thanks for the help.

local Tool = script.Parent
xSize = 3
ySize = 1
zSize = 5
Mouse = game.Players.LocalPlayer:GetMouse()
newBlock = nil
local Model = Instance.new("Model",workspace)

function createSingleInstance()
--  print(Mouse.Target)
--  print(type(Mouse.Target))
    if Mouse.Target.Name == "Baseplate" then

        local groundBlock = Instance.new("Part",workspace.Model)
        groundBlock.Name = "Block"
        groundBlock.Anchored = true
        groundBlock.Size = Vector3.new(xSize,ySize,zSize)
        groundBlock.Material = Enum.Material.Plastic
        groundBlock.Transparency = 1
        groundBlock.Position = Mouse.Hit.p

        groundBlock.BackSurface = Enum.SurfaceType.Smooth
        groundBlock.BottomSurface = Enum.SurfaceType.Smooth  
        groundBlock.FrontSurface = Enum.SurfaceType.Smooth    
        groundBlock.LeftSurface = Enum.SurfaceType.Smooth    
        groundBlock.RightSurface = Enum.SurfaceType.Smooth 
        groundBlock.TopSurface = Enum.SurfaceType.Smooth 

        groundBlock.Transparency = .9
        wait (.01)
        groundBlock.Transparency = .8
        wait (.01)
        groundBlock.Transparency = .7
        wait (.01)
        groundBlock.Transparency = .6
        wait (.01)
        groundBlock.Transparency = .5
        wait (.01)
        groundBlock.Transparency = .4
        wait (.01)
        groundBlock.Transparency = .3
        wait (.01)
        groundBlock.Transparency = .2
        wait (.01)
        groundBlock.Transparency = .1
        wait (.01)
        groundBlock.Transparency = 0

    elseif Mouse.Target.Name == "Block" then

        local newBlock = Instance.new("Part",workspace.Model)
        local target = Mouse.Target
        newBlock.Name = "Block"
        newBlock.Anchored = true
        newBlock.Size = Vector3.new(3,3,3)
        newBlock.Transparency = 1
        newBlock.Position = Mouse.Hit.p -- nearest surface?

        newBlock.BackSurface = Enum.SurfaceType.Weld  
        newBlock.BottomSurface = Enum.SurfaceType.Weld  
        newBlock.FrontSurface = Enum.SurfaceType.Weld  
        newBlock.LeftSurface = Enum.SurfaceType.Weld  
        newBlock.RightSurface = Enum.SurfaceType.Weld
        newBlock.TopSurface = Enum.SurfaceType.Weld

        --newBlock.CFrame = otherBlock.CFrame * CFrame.new(0, newBlock.Size.Y / 2 + otherBlock.Size.Y / 2, 0)


        workspace.Model:MakeJoints()
        newBlock.Anchored = false

        newBlock.Transparency = .9
        wait (.01)
        newBlock.Transparency = .8
        wait (.01)
        newBlock.Transparency = .7
        wait (.01)
        newBlock.Transparency = .6
        wait (.01)
        newBlock.Transparency = .5
        wait (.01)
        newBlock.Transparency = .4
        wait (.01)
        newBlock.Transparency = .3
        wait (.01)
        newBlock.Transparency = .2
        wait (.01)
        newBlock.Transparency = .1
        wait (.01)
        newBlock.Transparency = 0

    end


end

Tool.Activated:Connect(createSingleInstance)

What it looks like in game: https://imgur.com/a/6tYFihh

0
Can't you just use normal Welds or WeldConstraints? compUcomp 417 — 4y
0
Yep moved to weld constraints and it works well. Gunt_r 31 — 4y
0
You could try Motor6D but you have to manually set the position with cframe. antoniorigo4 117 — 4y

1 answer

Log in to vote
0
Answered by
haba_nero 386 Moderation Voter
4 years ago

Use a weld plugin. They are free and weld things together without silly scripts. Hope this helped! Link: https://www.roblox.com/library/148570182/Weld-Plugin/

0
Yea their useful. But doesn't seem so useful in this situation. antoniorigo4 117 — 4y
Ad

Answer this question