So I keep getting the error, String expected, got object. Line 5: Bad argument #2 to '?'
NormalParts = {["Slab"] = true,["Wall"] = true,["Plate"] = true} local event = script.BlockInsertation event.OnServerEvent:connect(function(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 script.Parent.MoneyDisplay.ErrorDisplay.Description.Text = "Undefined part value" script.Parent.MoneyDisplay.ErrorDisplay:TweenPosition(UDim2.new(0.8, 0,0.9, 0),"InOut","Linear",1,false) for i = 5, 1, -1 do wait(1) script.Parent.MoneyDisplay.ErrorDisplay.Timer.Text = i end script.Parent.MoneyDisplay.ErrorDisplay:TweenPosition(UDim2.new(1.3, 0,0.9, 0),"InOut","Linear",1,false) script.Parent.MoneyDisplay.ErrorDisplay.Timer.Text = "tim" end end end)
I only looked at the first few lines of the script based on your error, so there may be another error later in the script.
The problem is that OnServerEvent
takes two parameters. The first one MUST be the player, and the second is all the argument(s). You only have "name" which is what I'm assuming your argument. You just need to set player as a parameter.
Fixed Code:
NormalParts = {["Slab"] = true,["Wall"] = true,["Plate"] = true} local event = script.BlockInsertation event.OnServerEvent:connect(function(player, name) --The first parameter is the player, and the second one is all your arguments. local chil = game.Workspace[name]:GetChildren() for i, v in pairs (chil) do for n, m in pairs(NormalParts) do if NormalParts[n] == 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 break else script.Parent.MoneyDisplay.ErrorDisplay.Description.Text = "Undefined part value" script.Parent.MoneyDisplay.ErrorDisplay:TweenPosition(UDim2.new(0.8, 0,0.9, 0),"InOut","Linear",1,false) for i = 5, 1, -1 do wait(1) script.Parent.MoneyDisplay.ErrorDisplay.Timer.Text = i end script.Parent.MoneyDisplay.ErrorDisplay:TweenPosition(UDim2.new(1.3, 0,0.9, 0),"InOut","Linear",1,false) script.Parent.MoneyDisplay.ErrorDisplay.Timer.Text = "tim" end end end end)
Here is the Wiki page on the event OnServerEvent.
If I helped you out, be sure to accept my answer!