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

Help with a tool? (Food type)

Asked by 8 years ago

Ok so, I have made a salad bowl tool for a salad bar I am working on. I didn't know how to weld the unions and parts so I got a script for that.

-- MasterWeld by Zephyred
-- Works for all types of parts, unions etc.
local exclude = {"Wheel"} -- Any object whose name is in this list will not be welded, for example wheels.

function WeldPair(x, y)
    local weld = Instance.new("Weld",x) 
    weld.Part0 = x
    weld.Part1 = y
    weld.C1 = y.CFrame:toObjectSpace(x.CFrame);
end

function WeldAll(model, main) -- model can be anything
    for i,v in pairs(exclude) do if (model.Name == v) then return end end
    if model:IsA("BasePart") then WeldPair(main, model) end
    for _,v in pairs(model:GetChildren()) do WeldAll(v, main) end   
end

function UnanchorAll(model) -- model can be anything
    if (model:IsA("BasePart")) then model.Anchored = false end
    for _,v in pairs(model:GetChildren()) do UnanchorAll(v) end
end

WeldAll(script.Parent, script.Parent.Part)
UnanchorAll(script.Parent)

script:Destroy() -- Done, clean script up.

Anywhoo, I've made a click part with the tool in lighting (so it's hidden) and in the part with a script for it.

local part = script.Parent
local detector = part.ClickDetector
local weapon = game.Lighting.WeaponName
local debounce = false

detector.MouseClick:connect(function(player)
if debounce == false then
local g = weapon:Clone()
g.Parent = player.Backpack
debounce = true
wait(2)
debounce = false 
end)

Sooo, I was testing it, and nothing happened. Nothing went into my inventory, so I was like hmm let me test this. So I put the tool into Starter gear and took it out of lighting,. So I could see it. When I clicked it, It just stayed it the same place And my arm was out like I had the tool in my hand but it was on the floor in the same place. I was just wondering on how to fix this or to have somebody possibly help me in Team Create? Anyway thanks!

EDIT I have figured out I need a new weld script or some teaching on how to weld. Turns out it was anchored I need the parts and unions to be welded and unanchored without flying out of place. -unknowedbeast

1
I put the code into a code block for you. You're welcome. User#6546 35 — 8y
0
Thanks unknowedbeast 0 — 8y

Answer this question