So I'm trying to send a name to a reciving script and then that script will find the player in the workspace, check if a part that is in the list is in the player, then clone it and put it in workspace.
The only reason I'm doing this is because of filtering enabled
The sending script: (Local)
local Player = game.Players.LocalPlayer Mouse.Button1Down:connect(function() local name = Player.Name game.Workspace.BlockInserter.BlockInsertation:Invoke(name) end)
The receiving script: (Normal)
NormalParts = {"Slab","Wall","Plate"} script.BlockInsertation.OnInvoke = function(name) local chil = game.Workspace[name]:GetChildren() for i, v in pairs (NormalParts) do if chil.Name == v then local clone = name[v]:Clone() clone.Parent = game.Workspace else -- game.Players.player.PlayerGui.MoneyDisplay.ErrorDisplay.Description.Text = "Undefined part value: "..i.." -- game.Players.player.PlayerGui.MoneyDisplay.ErrorDisplay:TweenPosition(UDim2.new(0.8, 0,0.9, 0),"InOut","Elastic",2.6,false) -- wait(15) -- game.Players.player.PlayerGui.MoneyDisplay.ErrorDisplay:TweenPosition(UDim2.new(-1, 0,0.9, 0),"InOut","Elastic",2.6,false) end end end
There is something I need to say, I do not know what you mean by "returning errors".
I think you should've just used a remote event instead of a remote function. If you want a way to find if the script errors then use pcall. Anyway, I see the errors in the Normal script.
local chil = game.Workspace[name]:GetChildren() --Part of code for i, v in pairs (NormalParts) do if chil.Name == v then --Chil is an array, not a single object. It's like saying: "Banana tastes sweet, blue, 231, and it also tastes purple." local clone = name[v]:Clone() clone.Parent = game.Workspace
You also need to include the player object into the script.
What I think you should do is use a remote event instead. Since there is no reason to add a remote function but to make the script longer.
local Player = game.Players.LocalPlayer Mouse.Button1Down:connect(function() local name = Player.Name game.Workspace.BlockInserter.BlockInsertation:FireServer(name) end)
NormalParts = {["Slab"] = true,["Wall"] = true,["Plate"] = true} script.BlockInsertation.OnServerEvent:connect(function(game:GetService("Players"):WaitForChild([PLAYER_NAME NEEDED HERE]),name) local chil = game.Workspace[name]:GetChildren() for i, v in pairs (chil) do if NormalParts[v.Name] then local clone = workspace:FindFirstChild(name).Slab:Clone() or workspace:FindFirstChild(name).Wall:Clone() or workspace:FindFirstChild(name).Plate:Clone() clone.Parent = game.Workspace else -- game.Players.player.PlayerGui.MoneyDisplay.ErrorDisplay.Description.Text = "Undefined part value: "..i.." -- game.Players.player.PlayerGui.MoneyDisplay.ErrorDisplay:TweenPosition(UDim2.new(0.8, 0,0.9, 0),"InOut","Elastic",2.6,false) -- wait(15) -- game.Players.player.PlayerGui.MoneyDisplay.ErrorDisplay:TweenPosition(UDim2.new(-1, 0,0.9, 0),"InOut","Elastic",2.6,false) end end end)
Hope it helps!
NormalParts = {"Slab","Wall","Plate"} script.BlockInsertation.OnInvoke = function(name) local chil = game.Workspace[name]:GetChildren() for i, v in pairs (NormalParts) do if chil.Name == v then local clone = name[v]:Clone() clone.Parent = game.Workspace else game.Players.player.PlayerGui.MoneyDisplay.ErrorDisplay.Description.Text = "Undefined part value: "..i.." game.Players.player.PlayerGui.MoneyDisplay.ErrorDisplay:TweenPosition(UDim2.new(0.8, 0,0.9, 0),"InOut","Elastic",2.6,false) wait(15) game.Players.player.PlayerGui.MoneyDisplay.ErrorDisplay:TweenPosition(UDim2.new(-1, 0,0.9, 0),"InOut","Elastic",2.6,false) end end end
Try removing the "--'s," that makes the line a comment. This isn't really an answer, just a recommendation.