Repost:
I want it so that when a user types another user's name into a TextBox and presses this button, the script searches for the player who's name was entered and checks to see if he's wearing a T-Shirt (I'd rather use :PlayerOwnsAsset but I can't get that to work either). Then, if the player was found owning that T-Shirt, they'd be given a tool. I've spent ages on this, I just don't know what's wrong. Please, could you help?
(I've covered up the itemID, it was an odd number).
user = script.Parent.Parent.Username
text = user.Text
dbnc = true
tool = game.Lighting.Card
clne = nil
script.Parent.MouseButton1Click:connect(function()
if dbnc == true then
dbnc = false
local plr = game.Players:FindFirstChild(text) -- finds the player who's name was entered into the textBox
if plr ~= nil then
local shrt = plr.Character:FindFirstChild("Shirt Graphic", true)
if shrt.Graphic == "http://www.roblox.com/item.aspx?id=NUMBER" then -- if player has shirt then
user.BackgroundColor3 = Color3.new(0, 255, 0)
wait(2)
user.BackgroundColor3 = Color3.new(255, 255, 255)
clne = tool:Clone()
clne.Parent = plr.Backpack
else -- if player does not have shirt
game:GetService("MarketplaceService"):PromptProductPurchase(plr, "http://www.roblox.com/asset/?id=NUMBER")
end
else -- if the player who's name was entered into the textBox could not be found
user.BackgroundColor3 = Color3.new(255, 0, 0)
wait(2)
user.BackgroundColor3 = Color3.new(255, 255, 255)
end
dbnc = true
end
end)

1 comment