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

It's keep saying 'then' expected near 'local' ?

It's say 'then' expected near 'local'

Here the script :

local name = "BlaBla"

local owner = game:GetService("Players")[name]

for i,v in pairs(game.ReplicatedStorage.API:GetChildren()) do if v:IsA("RemoteFunction") local A_1 = "BlaBla" local A_2 = owner v:InvokeServer(A_1, A_2) end

1 answer

in Lua if statements needs to have then after the condition, like this

if (something) then
	
	local A_1...

	...

You need to add one in your case

...

for i,v in ipairs(game.ReplicatedStorage.API:GetChildren()) do

	if v:IsA("RemoteFunction") then --|then
		local A_1 = "BlaBla"
		local A_2 = owner
		v:InvokeServer(A_1, A_2)
	end -- if statements needs to be ended too
end

end is also necessary, otherwise it will error too.

Here is Lua documentation on if statements.

Also when getting player from Players, it's good to use FindFirstChild as for example this user will break the function as it will call GetPlayers method.

local name = "BlaBla"

local owner = game:GetService("Players"):FindFirstChild(name)

This will make sure the player is child and not property/method.

2 comments

0

Thanks so much it's worked

0

Set his reply to an answer

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