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

Hat giver not working?

Asked by
Vividex 162
10 years ago

Script inside of the button:

sp = script.Parent

function GiveTheHat()
    GetID = script.Parent.Parent.ID.Text
    GiveIt = game:GetService("InsertService"):LoadAsset(GetID)
    GiveIt.Parent = game.Workspace
    GiveIt:MoveTo(game.Players.LocalPlayer.Character.Head.Position)
end

script.Parent.MouseButton1Down:connect(GiveTheHat)

The hat spawns in Workspace but does not let anyone put it on there head or creates it where the head is. Any help please? (Also if you can explain to me, how would I just ctrl + v the ID into the text instead of typing it?)

2 answers

Log in to vote
0
Answered by 10 years ago

Hmm, try this instead;

repeat wait(0)until game.Players.LocalPlayer and game.Players.LocalPlayer.Character and script.Parent and script.Parent.Parent and script.Parent.Parent:FindFirstChild("ID")
local sp = script.Parent
function GiveTheHat()
GetID = sp.Parent.ID.Text
GiveIt = game:GetService("InsertService"):LoadAsset(GetID)
for i,v in pairs(GiveIt) do
if v:IsA("Hat" ) or v:IsA("Tool") then
v.Parent = game.Players.LocalPlayer.Character
end
end
end
script.Parent.MouseButton1Down:connect(GiveTheHat)
Ad
Log in to vote
-2
Answered by 10 years ago

The reason you can't put it on your head is because all Hats have a script and a TouchInterest in them, causing them to go onto the Player's head. I suggest you insert the hat, then clone a TouchInterest and a script with Pre-Made code (just use a script inside of any free modeled hat) and clone them into the Hat you inserted.

I won't write the code for you, but I hope you understand what I mean.

Answer this question