How can I pass the variable of the model from the server to the client using remote events?

I want to be able to send the model variable defined in the server to the client.

When ever I fire to the players client the variable becomes nil. I plan to have multiple mannequins so I don’t want to individually define them in the local script.

This is the server script

local prompt = script.Parent.ProximityPrompt
local event = game.ReplicatedStorage.OutfitGui


prompt.Triggered:Connect(function(player)
	local manne = script.Parent
	print(manne)
	event:FireClient(player, manne)
	return manne
end)

This is the Local script

local event = game.ReplicatedStorage.OutfitGui

local gui = script.Parent.Frame
local ap = gui.AbsolutePosition
local tween = game:GetService("TweenService")
local icon = "http://www.roblox.com/Thumbs/Asset.ashx?width=50&height=50&assetid="

event.OnClientEvent:Connect(function(player, manne)
	--print(model.Name)
	gui.Position = UDim2.new(0.25, 0, -.50, 0)
	gui.Visible = true
	gui:TweenPosition(UDim2.new(0.25, 0, 0.25, 0), "In","Linear", .25, true)
	--for i, v in pairs(game.Workspace.luvurzz:GetDescendants()) do
	for i, v in pairs(manne:GetDescendants()) do
		if v:IsA("Accessory") then
			local id = v:FindFirstChild("AssetId")
			local itemgui = game.ReplicatedStorage.ImageButton:Clone()
			itemgui.Parent = gui.ScrollingFrame
			itemgui.Image = icon..id.Value

		end
	end
end)

When the client is fired the manne variable turns to nil.

Its because in the OnClientEvent, the player argument is not necessary, because its already running on the client. So the argument called “player” is the model, and manne is nil, so just delete player argument and thats it.

event.OnClientEvent:Connect(function(manne)
2 Likes

Oh it works thanks for the help

1 Like

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