-
What do you want to achieve? I want my pet inventory system work
-
What is the issue? After some debugging, i found petName isn’t nil. aswell as the Display frame is present in the template
-
What solutions have you tried so far? I tried looking at devforum and youtube and devhub
local rep = game:GetService("ReplicatedStorage")
local runs = game:GetService("RunService")
local model3D = require(rep:WaitForChild("Module3D"))
local tweeny = game:GetService("TweenService")
local uis = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local frame = script.Parent
local info = frame.Info
local displaypet = info.Displayframe
local container = frame.scroller
local temp = container.Temp
local selecte = nil
local petnaame = info.name
local equipbtn = info.equipbtn
local unequipall = info.Unequipall
local function temppress(temp)
selecte = temp
petnaame.Text = temp.Name
if selecte:FindFirstChild("Equipped").Value == true then
equipbtn.TextLabel.Text = "Unequip"
selecte:FindFirstChild("Equipped").Value = true
else
equipbtn.TextLabel.Text = "Equip"
selecte:FindFirstChild("Equipped").Value = false
end
for i,v in pairs(displaypet:GetChildren()) do
if v:isA("ViewportFrame") then
v:Destroy()
end
end
local petmodel = model3D:Attach3D(displaypet,rep.Pets:FindFirstChild(temp.Name , true):Clone())
petmodel:SetDepthMultiplier(1.2)
petmodel.Camera.FieldOfView = 5
petmodel.Visible = true
runs.RenderStepped:Connect(function()
petmodel:SetCFrame(CFrame.Angles(0,tick() % (math.pi * 2),0) * CFrame.Angles(math.rad(10),0,0))
end)
end
local function equippet()
if selecte ~= nil then
if selecte:FindFirstChild("Equipped").Value == false then
local result = rep.EggHatchingRemotes.Equippet:InvokeServer(selecte.Name)
if result == "Equip" then
equipbtn.TextLabel.Text = "Unequip"
selecte.checku.Visible = true
selecte:FindFirstChild("Equipped").Value = true
elseif result == "Unequip"then
equipbtn.TextLabel.Text = "Equip"
selecte:FindFirstChild("Equipped").Value = false
selecte.checku.Visible = false
end
else
local result = rep.EggHatchingRemotes.Unequippet:InvokeServer(selecte.Name)
if result == true then
equipbtn.TextLabel.Text = "Equip"
selecte.checku.Visible = false
selecte:FindFirstChild("Equipped").Value = false
end
end
end
end
_G.newTemp = function(petName)
print(petName)
local newtemp = temp:Clone()
newtemp.Name = tostring(petName)
newtemp.Visible = true
newtemp.Parent= container
--where the error comes
local petmodel = model3D:Attach3D(newtemp.Display,rep.Pets:FindFirstChild(petName.Name,true):Clone())
petmodel:SetDepthMultiplier(1.2)
petmodel.Camera.FieldOfView = 5
petmodel.Visible = true
runs.RenderStepped:Connect(function()
petmodel:SetCFrame(CFrame.Angles(0,tick() % (math.pi * 2),0) * CFrame.Angles(math.rad(-10),0,0))
end)
newtemp.MouseButton1Click:Connect(function()
temppress(newtemp)
end)
end
equipbtn.MouseButton1Click:Connect(function()
equippet()
end)
unequipall.MouseButton1Click:Connect(function()
for i,v in pairs(container:GetChildren()) do
if v:isA("ImageButton") then
v:FindFirstChild("Equipped").Value = false
v.checku.Visible = false
end
end
rep.EggHatchingRemotes.Unequipall:FireServer()
end)
Thanks in advance!