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

Whats Wrong with this script?

Asked by
iLegitus 130
10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.
SH = SpaceHat


script.Parent.Touched:connect(function(hit)
if  hit.Parent:FindFirstChild(SH) ~= nil then
    hit.Parent.Head.BrickColor = BrickColor.new("White")
    hit.Parent.Head.face:remove()
    hit.Parent.Head:BreakJoints()

end
end)

SH = SpaceHat

Please help.

1 answer

Log in to vote
1
Answered by 10 years ago

i think you need to put quotation marks on the word SpaceHat like this.

SH = "SpaceHat"

and you need to remove the word "Head" on line 8 and it should be like this:

hit.Parent:BreakJoints()

because BreakJoints only works on Model.

the script should be like this:

SH = "SpaceHat"


script.Parent.Touched:connect(function(hit)
if  hit.Parent:FindFirstChild(SH) ~= nil then
    hit.Parent.Head.BrickColor = BrickColor.new("White")
    hit.Parent.Head.face:remove()
    hit.Parent:BreakJoints()

end
end)

i hope it helps.

Ad

Answer this question