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

weird glitch with player hat giver specific question?

Asked by 5 years ago

ok so bsically i have a hat give on my game and it was working a month ago but my broter shut down my pc without me saving my progres so i had to remake the giver and now its not working anymore for some weird reason and i havent been scripting much lately so it could be im missing something idk but i doubt it cause im an expert scripter so it probalby is a glitch but i just want to make sure. hers my code

giver = workspace.club.givers.hatgivers.tophat
hat = workspace.hats.tophat

giver.Touched:Connect(function(hit)
    clone = hat:Clone()
    clone.Parent = hit.Head
end)

2 answers

Log in to vote
1
Answered by
Despayr 505 Moderation Voter
5 years ago

The 'hit' parameter of the 'Touched' function references a touched part, not a model. You are trying to search for the head of a character through that touched part.

On line 7, simply do

clone.Parent = hit.Parent.Head
Ad
Log in to vote
0
Answered by 5 years ago

Put the hat in lighting and try something like this!

giver = workspace.club.givers.hatgivers.tophat
Lighting = game:GetService("Lighting")
Hat = Lighting.Hat

giver.Touched:Connect(function(hit)
    clone = hat:Clone()
    clone.Parent = hit.Head
end)

Answer this question