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

Can you help fixing shirt/pants buy script?

Asked by 6 years ago

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

Log in to vote
0
Answered by 6 years ago

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.

Ad

Answer this question