Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

RemoteFunction not returning errors help?

Asked by
NotSoNorm 777 Moderation Voter
9 years ago

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
0
Did you use a RemoteEvent or a RemoteFunction when you tried my script? EzraNehemiah_TF2 3552 — 9y
0
I used RemoteEvent NotSoNorm 777 — 9y

2 answers

Log in to vote
1
Answered by 9 years ago

Before I start,

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.


Error

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.


Final Product

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 Script

local Player = game.Players.LocalPlayer

Mouse.Button1Down:connect(function()
    local name = Player.Name
    game.Workspace.BlockInserter.BlockInsertation:FireServer(name)
end)

Regular Script

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!

0
Oooo, Ok, But I think there is an error on line 3, The 'function(game:GetService("Players")' the ':' after game is red saying it expected ')' to close at colom 49 NotSoNorm 777 — 9y
Ad
Log in to vote
0
Answered by 9 years ago
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.

Answer this question