local player = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent
Cost = 5
function checkForChocolateMilk()
local found = false
for i, v in pairs(player.Backpack:GetChildren()) do
if v.Name == "ChocolateMilk"
then
found = true
end
end
for i, v in pairs(player.Character:GetChildren()) do
if v.Name == "ChocolateMilk"
then
found = true
end
end
if found == true
then
return true
else
return false
end
end
script.Parent.MouseButton1Click:Connect(function()
local leaderstats = player:FindFirstChild("leaderstats")
if leaderstats then
local Points = leaderstats:FindFirstChild("Points")
if Points then
local hasChocolateMilk = checkForChocolateMilk()
if Points.Value >= Cost and hasChocolateMilk == false then
Points.Value = Points.Value - Cost
local ChocolateMilk = game.ServerStorage.ChocolateMilk:Clone()
ChocolateMilk.Parent = player.Backpack
end
local found = false
for i, v in pairs(player.Backpack:GetChildren()) do
if v.Name == "ChocolateMilk" then
found = true
break
end
end
if found == true then
script.Parent.Visible = false
player.PlayerGui.MainShop.OEE.BuyChocoMilk.ChocolateMilkOwned.Visible = true
script.Parent.Roundify.ImageColor3 = Color3.fromRGB(255, 44, 47)
end
end
end
end)
COMMUNITY QUESTION
why does this not make the ChocolateMilkOwned show up and give me chocolate milk?
0 answers
No public answers were preserved for this question.
This discussion is preserved as it was. New answers, comments, and votes are closed.
