Mag is not a valid member of Model

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I
  2. What is the issue? Include screenshots / videos if possible!
    The LocalScript cannot find the unionoperation named Mag in a model of replicatedstorage when it clearly is there
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried looking for solutions, used waitforchild() and nothing works
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
    This is my script:
local buttons = script.Parent.Parent.Parent.Frame.Buttons
local selected = buttons.selected
local info = script.Parent.Parent.Parent.Info
for _,i in pairs(buttons:GetChildren()) do
	if i:IsA("TextButton") then
		i.MouseButton1Down:Connect(function()
			selected.Value = i.Name
		end)
	end
	
end

selected.Changed:Connect(function(val)
	local ViewportFrame = script.Parent.Parent.ViewportFrame-- Viewport Frame Here.
	local Model = game.ReplicatedStorage:WaitForChild("ACS_Engine"):WaitForChild("GunModels"):WaitForChild("Client"):WaitForChild(val):Clone()--Put your model here, and clone it with :Clone()
	Model.Parent = ViewportFrame
	local Camera = Instance.new("Camera")
	ViewportFrame:ClearAllChildren()
	Camera.Parent = ViewportFrame
	Camera.CFrame = CFrame.new((Model:WaitForChild("Mag").CFrame * CFrame.new(0,0,-8)).Position + Vector3.new(3,0,0), Model:WaitForChild("Mag").Position) -- This is where you would adjust your camera. Be sure to have a PrimaryPart in your model if you are doing a direct copy and paste.
	Camera.FieldOfView = 30
	ViewportFrame.CurrentCamera = Camera
	info.TextLabel.Text = val
	info.Stats.magsize.Text = "Capacity: "..require(game.ReplicatedStorage:FindFirstChild(val).ACS_Modulo.Variaveis.Settings).Ammo
	info.Stats.recoil.Text = "Recoil: "..require(game.ReplicatedStorage:FindFirstChild(val).ACS_Modulo.Variaveis.Settings).VRecoil[1]
	info.Stats.damage.Text = "Damage: "..require(game.ReplicatedStorage:FindFirstChild(val).ACS_Modulo.Variaveis.Settings).LimbsDamage[1]
end)
info.Buy.MouseButton1Down:Connect(function()
	local buy = game.ReplicatedStorage.events.BuyItem
	local plr = game.Players.LocalPlayer
	buy:FireServer(game.ReplicatedStorage:FindFirstChild(selected.Value))
end)

image
This is the model, and as you can see, the Mag union is there.
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Fixed the problem. I called clearallchildren() after setting the model’s parent to the viewport.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.