I'm using :InvokeServer() in a GUI's LocalScript yet Lua is telling me that the function can only be called from the client.

Like err.. hello, it's a localscript.

Here's the output:

04:18:30.811 - InvokeServer can only be called from the client
04:18:30.811 - Script 'Players.Player1.PlayerGui.GameGUI.Main.BuyFrame.PurchaseController', Line 77 - global placeBuilding
04:18:30.811 - Script 'Players.Player1.PlayerGui.GameGUI.Main.BuyFrame.PurchaseController', Line 100 - global mouseClick
04:18:30.811 - Script 'Players.Player1.PlayerGui.GameGUI.Main.BuyFrame.PurchaseController', Line 28
04:18:30.812 - Stack End

Here's the code:

function placeBuilding(b, cost)
	local bPos = b.Base.Position
	local bName = b.Name
	b.Parent = models.Temp
	//Following line contains the error
	local success = game.Workspace.buildRemFunc:InvokeServer(mode, bPos, bName, cost)
	if success == true then
		placed = 1
		return true
		//and so on

Here's the hierarchy: Click here to see image

What's going on? Am I using it wrong?

3 comments

0

I've never seen this issue before. Do you get these errors in online mode, in the F9 server log?

0

That's odd. Try putting the remotefunction in RepliactedStorage

0

I'm getting the errors in the Local log, which is even more weird. I'll try putting the functions in replicatedstorage next, thanks.