Im trying to make a pet trade button but it only works every so often in roblox studio?
Asked by
5 years ago Edited 5 years ago
Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.
local load = false
local x = 0
script.Parent.MouseButton1Down:Connect(function()
local plr = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent
for i,v in pairs(plr:WaitForChild("Pets"):GetChildren())do
for i=1,1 do
if load == false then
load = true
for f,g in pairs(script.Parent.Parent.Parent.Parent:WaitForChild("Items1"):GetChildren())do
if g.Name == script.Parent.Parent.Name then
x=x+1
end
end
if v.Value > x then
local a = Instance.new("StringValue")
a.Name = script.Parent.Parent.Name
local SP = game.ReplicatedStorage:WaitForChild("Pets")
local ff = SP:WaitForChild(script.Parent.Parent.Name)
a.Value = ff:WaitForChild("Icon").Value
a.Parent = script.Parent.Parent.Parent.Parent:WaitForChild("Items1")
end
end
end
end
load = false
x=0
end)