So I am making a GUI shop for my minigame place. The problem is, that in the Hats/Hair column, this script doesn't work. Why? And there are no errors.

local name = script.Parent.Parent.NameOfItem
local gear1 = game.Lighting.RainbowGirlHair
local gear2 = game.Lighting.GirlBlondeHair
local gear3 = game.Lighting.Helmet
local gear4 = game.Lighting.BlondeHair
local char = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Character
print(char.Name)
local points = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Points
local head = char.Head
script.Parent.MouseButton1Down:connect(function()
	if name.Value == gear1.Name then
		if points.Value >= 150 then
			points.Value = points.Value - 150
			local gear12 = gear1:Clone()
			gear12.Parent = char
			gear12.Handle.Position = head.Position
			gear12.AttachmentPos = Vector3.new(0, -0.25, 0)
		else
			script.Parent.Text = "Not Enough!"
			wait(2)
			script.Parent.Text = 'BUY'
		end
	elseif name.Value == gear2.Name then
		if points.Value >= 150 then
			points.Value = points.Value - 150
			local gear22 = gear2:Clone()
			gear22.Parent = char
			gear22.Handle.Position = head.Position
			gear22.AttachmentPos = Vector3.new(0, -0.25, 0)
		else
			script.Parent.Text = "Not Enough!"
			wait(2)
			script.Parent.Text = 'BUY'
		end
	elseif name.Value == gear3.Name then
		if points.Value >= 150 then
			points.Value = points.Value - 150
			local gear32 = gear3:Clone()
			gear32.Parent = char
			gear32.Handle.Position = head.Position
			gear32.AttachmentPos = Vector3.new(0, -0.25, 0)
			print("Purchased!")
		else
			script.Parent.Text = "Not Enough!"
			wait(2)
			script.Parent.Text = 'BUY'
		end
	elseif name.Value == gear4.Name then
		if points.Value >= 150 then
			points.Value = points.Value - 150
			local gear42 = gear4:Clone()
			gear42.Parent = char
			gear42.Handle.Position = head.Position
			gear42.AttachmentPos = Vector3.new(0, -0.25, 0)
		else
			script.Parent.Text = "Not Enough!"
			wait(2)
			script.Parent.Text = 'BUY'
		end
	end
end)

4 comments

0

add more prints. does it get through the if statements?

0

hats already handle welds by themselves, setting the position of the handle will break it and changing the AttachmentPos messes with the orientation.

0

@1waffle1 I did the prints, it did not print at all.

0

I think it probably breaks on the character part... try a 'repeat wait() until char' before printing.