Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I am getting an error when I use remotefunctions?

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

✓ Accepted answer

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

2 comments

0

ok let me try it

1

Thank you so much i was stuck on this for soooooo long

This discussion is preserved as it was. New answers, comments, and votes are closed.