local HolderFrame = script.Parent.Holder
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Trails = ReplicatedStorage.Trails

local player = game.Players.LocalPlayer
local character = player.Character



if not character or not character.Parent then
	character = player.CharacterAdded:wait()
end

for i,v in pairs(HolderFrame:GetChildren()) do
	if v:IsA("TextButton") then
		v.MouseButton1Click:Connect(function()
			if v.Purchased.Value == false then
				if player.leaderstats.Points.Value >= v.Cost.Value then
					player.leaderstats.Points.Value = player.leaderstats.Points.Value - v.Cost.Value
					v.Purchased.Value = true
					v.Status.Text = "Purchased"
				else
					print("Not Enough")
				end
			elseif v.Purchased.Value == true then
				if not character:FindFirstChild(v.Name) then
					for i,v in pairs(character:GetChildren()) do
						if v:IsA("Trail") then
							v:remove()
						end
					end
				local trail = v.Name
				local trailCopy = Trails[trail]:Clone()
				trailCopy.Parent = character
				trailCopy.Attachment0 = character.Head.At1
				trailCopy.Attachment1 = character.HumanoidRootPart.At2
				end
			end
		end)
	end
end

1 comment

0

it worked