Hello,

I am having trouble with my shop gui. Basically I made two gamepasses, one for a red trail and one for a blue trail. In the shop gui when the buttons are clicked the prompt to buy the gamepass works. What doesn't work, is the unequip and equip feature. My script is not working and what I want to do is make it so that if the gamepass is owned, when the button is clicked, the trail is equipped. Here is the current equip code:


game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		local attachment0 = Instance.new("Attachment", char.Head)
		local attachment1 = Instance.new("Attachment", char.HumanoidRootPart)
		attachment0.Name = "TrailAttach0"
		attachment1.Name = "TrailAttach1"
	end)
end)


game.ReplicatedStorage.TrailShopRemotes.EquipTrail.OnServerEvent:Connect(function(player, trail)
	
	player.OwnedTrails:FindFirstChild(trail) 
		for i, iftrail in pairs(player.Character:getChildren()) do
			if iftrail:IsA("Trail") then
				iftrail:Destroy()
			end
		end
	
	
	local clone = game.ServerStorage.Trails:FindFirstChild(trail):Clone()
	clone.ItemNumber:Destroy()
	clone.Cost:Destroy()
	clone.Boost:Destroy()
	clone.Parent = player.Character
	clone.Attachment0 = player.Character.Head.TrailAttach0
	clone.Attachment1 = player.Character.HumanoidRootPart.TrailAttach1
	player.TrailEquipped.Value = trail
	local strail = game.ServerStorage.Trails:FindFirstChild(trail)
	player.Boost.Value = strail.Boost.Value
	game.ReplicatedStorage.TrailShopRemotes.EquipTrail:FireClient(player, trail)
end)

##[Edit By JesseSong:] Please ensure use grammar when forming sentences so that they are consise. Also make sure you use a code block when adding code so it can be easier for the community to answer your questions correctly. If you'd like to learn about posting good question/answers click on the hyperlink provided

Thanks, JesseSong!

1 comment

0

Can you answer the question though?