Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can you help fixing shirt/pants buy script?

I need help fixing my script that when clicked on a part buys pants with at leader stat named money and equips it to their character, help would be largely appreciated.

local pants = script.Parent.Parent.Parent.Char.Pants
Money = player.leaderstats.Money

script.Parent.ClickDetector.MouseClick:connect(function(player)
	if player.Character ~= nil and Money.value = >100 then -- (100 is cost)
		if player.Character:FindFirstChild("Pants") then
                        Money.value = -100
			player.Character["Pants"]:remove()
			pants:Clone().Parent = player.Character
		else
			pants:Clone().Parent = player.Character
		end
	end
end)

1 answer


local pantsId = 0 -- change this Id to whatever you want
local Players = game:GetService('Players') -- wait for players
local player = game.Players.LocalPlayer -- local player
local Money = player:WaitForChild("leaderstats").Money --wait for money to load

script.Parent.ClickDetector.MouseClick:connect(function()
       if Money.Value >= 100 then -- If money equals or is greater than 100
	player.Character:FindFirstChild("Pants").PantsTemplate = pantsId --change pants
	else
	print("You do not have 100 cash")
 end
end)

You have a lot of mistakes. Try and understand my code and learn of the Roblox Wiki. There are also plenty of online YouTube tutorials.

This discussion is preserved as it was. New answers, comments, and votes are closed.