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

I am getting an error when I use remotefunctions?

Asked by 3 years ago

Ok so I was trying to use a RemoteFunction and this is my Client Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local QuakeF = game.ReplicatedStorage.QuakeF
local QuakeForce = ReplicatedStorage.BodyForce


script.Parent.MouseButton1Click:Connect(function()


    QuakeF:InvokeServer()

end)

And this is my Server Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local QuakeF = game.ReplicatedStorage.QuakeF

QuakeF.OnServerInvoke = function(player)
print("do something please")
    for i,v in pairs(game.Workspace) do
        if v.Humanoid then
            v.Humanoid.Sit = true

            print("please do something")
        end
    end


end

But i got this error message that says "  13:15:15.834 ServerScriptService.EarthquakeScript:6: invalid argument #1 to 'pairs' (table expected, got Instance)  -  Client  -  QuakeMove:9"

can anyone help me?

1 answer

Log in to vote
1
Answered by 3 years ago

You Forgot To Use Get Children On You For Loop

Server Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local QuakeF = game.ReplicatedStorage.QuakeF

QuakeF.OnServerInvoke = function(player)
print("do something please")
    for i,v in pairs(game.Workspace:GetChildren()) do
        if v:FindFirstChild("Humanoid") then
            v.Humanoid.Sit = true

            print("please do something")
        end
    end


end
0
ok let me try it Littlebigplanet40000 77 — 3y
1
Thank you so much i was stuck on this for soooooo long Littlebigplanet40000 77 — 3y
Ad

Answer this question