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

Hat script gives hat but doesn't weld to head?

Asked by 7 years ago

Here is my script. It gives the hat and everything, except it doesn't stick the the players head:

01local debounce = true
02local timeinterval = 1
03local mesh = script.Parent.Mesh
04 
05script.Parent.Touched:connect(function(player)
06    local humanoid = player.Parent:FindFirstChild("Humanoid")
07    if humanoid then
08        print("there is humanoid")
09        if not debounce then
10            return
11        end
12        debounce = false
13        --HatGive--
14        local hat = Instance.new("Hat")
15        local handle = Instance.new("Part")
View all 33 lines...

why wont it weld to the characters head? ty for feedback pls

1 answer

Log in to vote
0
Answered by 7 years ago

I had the same problem you are having for almost 2 weeks. I think I may be able to help.

So heres the code I use for my script. Just for you to look at, maybe bounce some ideas off of.

1-- Parents objects to character
2ClothingStorage.Imperials.AssaultClass.Helmet:clone().Parent = Character
3Character.Helmet.Handle.AccessoryWeld.Part0 = Character.Helmet.Handle
4Character.Helmet.Handle.AccessoryWeld.Part1 = Character.Head

What is does is it goes into ClothingStorage which is a folder inside ReplicatedStorage for me.

Then it parents the helmet to the character. The helmet is an accessory, it has all the parts inside it including a weld script and a handle.

Inside the handle is a weld.

It sets the welds to the helmet and then the other weld to the head.

Now back to you


Looking back at your script, it seems no where in your script do you actually create the weld.

So lets do that now :)

Anywhere there is a ------------- That means I have added that line

01local debounce = true
02local timeinterval = 1
03local mesh = script.Parent.Mesh
04 
05script.Parent.Touched:connect(function(player)
06    local humanoid = player.Parent:FindFirstChild("Humanoid")
07    if humanoid then
08        print("there is humanoid")
09        if not debounce then
10            return
11        end
12        debounce = false
13        --HatGive--
14        local hat = Instance.new("Hat")
15        local handle = Instance.new("Part")
View all 42 lines...

Tell me if that works, I am not the best scripter in the world. So if it doesnt work then comment and ill see if I can fix it. :)

0
It works thanks so much! I dont really use welds because I dont use them correctly so they seem difficult lol but it worked! MusicalDisplay 173 — 7y
0
Youre welcome my dude! Anything I can do to help :) GottaHaveAFunTime 218 — 7y
Ad

Answer this question