I not understanding, why is it working really strange

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

  1. I want create system of platters. Cook is can put dishes to platter and give it to other players.

  2. Platter system working on third platter very strange. 2 last dishes not putting to platter.

  3. On DevForum I’m don’t finded information.

Please help me! It’s three scripts for platters.
PlatterClient

local module = require(game.Lighting.PlatterModule)

local plr = game.Players.LocalPlayer

repeat wait() until plr.Character

script.Parent.Equipped:Connect(function()
	if plr.PlayerGui:FindFirstChild("Platter"..script.Parent.ID.Value) then
		module.guiEnable(plr.PlayerGui:FindFirstChild("Platter"..script.Parent.ID.Value))
	end
end)

script.Parent.Unequipped:Connect(function()
	if plr.PlayerGui:FindFirstChild("Platter"..script.Parent.ID.Value) then
		module.guiDisable(plr.PlayerGui:FindFirstChild("Platter"..script.Parent.ID.Value))
	end
end)

local debounce = false

plr.PlayerGui:FindFirstChild("Platter"..script.Parent.ID.Value).PlatterSet.Changed:Connect(function()
	local gui = plr.PlayerGui:FindFirstChild("Platter"..script.Parent.ID.Value)
	if gui.PlatterSet.Visible == true then
		if debounce == false then
			debounce = true
			for i, v in pairs(plr.Backpack:GetChildren()) do
				if v.ClassName == "Tool" and v.PrimaryPart ~= nil and v.Name ~= "Platter" then
					local clone = game:GetService("ReplicatedStorage").PlatterTemplate:Clone()
					clone.Parent = gui.PlatterSet.Inventory
					clone.Name = v.Name
					clone.TextLabel.Text = v.Name
					module.tmpHandle(plr, gui, clone)
				end
			end
		end
	else
		debounce = false
	end
end)

PlatterModule

local PlatterModule = {}

local RS = game:GetService("ReplicatedStorage")
local SS = game:GetService("ServerStorage")
local template = RS:WaitForChild("PlatterTemplate")

PlatterModule.guiPut = function(plr, gui, val)
	local clone = gui:Clone()
	clone.Parent = plr.PlayerGui
	clone.Name = "Platter"..tostring(val)
	clone.ID.Value = val
end

PlatterModule.guiEnable = function(gui)
	gui.Enabled = true
end

PlatterModule.guiDisable = function(gui)
	gui.Enabled = false
	gui.PlatterSet.Visible = false
	gui.Frame.Visible = true
end

PlatterModule.tmpHandle = function(plr, gui, tmp)
	tmp.TextButton.MouseButton1Click:Connect(function()
		if tmp.Parent.Name == "Inventory" then
			local num = 0
			local platter = plr:FindFirstChild("Platter"..tmp.Parent.Parent.Parent.ID.Value).Value
			for i, v in pairs(gui.PlatterSet.Platter:GetChildren()) do
				if v.ClassName == "Frame" then
					num = num + 1
				end
			end
			if num < 6 then
				local ID = tmp.Parent.Parent.Parent.ID.Value
				tmp.Parent = tmp.Parent.Parent.Platter
				game:GetService("ReplicatedStorage").Remotes:WaitForChild("Platter1"):FireServer(plr, platter, plr.Backpack:FindFirstChild(tmp.Name), ID)
			end
		elseif tmp.Parent.Name == "Platter" then
			local ID = tmp.Parent.Parent.Parent.ID.Value
			local platter = plr:FindFirstChild("Platter"..tmp.Parent.Parent.Parent.ID.Value).Value
			tmp.Parent = tmp.Parent.Parent.Inventory
			game:GetService("ReplicatedStorage").Remotes:WaitForChild("Platter2"):FireServer(plr, platter, platter:FindFirstChild(tmp.Name), ID)
		end
	end)
end

return PlatterModule

PlatterServer

game:GetService("ReplicatedStorage").Remotes:WaitForChild("Platter1").OnServerEvent:Connect(function(plr, player, platter, tool, id)
	if platter.ID.Value == id then
		tool.Parent = platter
		local toolPosPart
		if platter.Podnos.Spawn1.Use.Value == false then
			toolPosPart = platter.Podnos.Spawn1
			toolPosPart.Use.Value = true
		elseif platter.Podnos.Spawn2.Use.Value == false then
			toolPosPart = platter.Podnos.Spawn2
			toolPosPart.Use.Value = true
		elseif platter.Podnos.Spawn3.Use.Value == false then
			toolPosPart = platter.Podnos.Spawn3
			toolPosPart.Use.Value = true
		elseif platter.Podnos.Spawn4.Use.Value == false then
			toolPosPart = platter.Podnos.Spawn4
			toolPosPart.Use.Value = true
		elseif platter.Podnos.Spawn5.Use.Value == false then
			toolPosPart = platter.Podnos.Spawn5
			toolPosPart.Use.Value = true
		elseif platter.Podnos.Spawn6.Use.Value == false then
			toolPosPart = platter.Podnos.Spawn6
			toolPosPart.Use.Value = true
		end

		if toolPosPart ~= nil then 
			tool:SetPrimaryPartCFrame(toolPosPart.CFrame)
			local weldConstraint = Instance.new("WeldConstraint")
			weldConstraint.Parent = tool.PrimaryPart
			weldConstraint.Name = "SpawnWeld"
			weldConstraint.Part0 = tool.PrimaryPart
			weldConstraint.Part1 = toolPosPart
			tool:SetPrimaryPartCFrame(toolPosPart.CFrame)
			for i, v in pairs(tool:GetChildren()) do
				if v.ClassName == "Part" or v.ClassName == "MeshPart" or v.ClassName == "UnionOperation" then
					v.CanTouch = false
					if v.Parent.Parent.Parent.Name == "PlatterSpawn" then
						v.Anchored = true
					end
				end
			end
		end
	end
end)

game:GetService("ReplicatedStorage").Remotes:WaitForChild("Platter2").OnServerEvent:Connect(function(plr, player, platter, tool, id)
	if platter.ID.Value == id then
		tool.PrimaryPart:FindFirstChild("SpawnWeld"):Destroy()
		tool.Parent = plr.Backpack
		for i, v in pairs(tool:GetChildren()) do
			if v.ClassName == "Part" or v.ClassName == "MeshPart" or v.ClassName == "UnionOperation" then
				v.CanTouch = true
				v.Anchored = false
			end
		end
	end
end)

And video of this moment:

1 Like