Code stops when hits an invoke server

I’m using an invoke server to send tables from the local script to a script and when I try using this the Invoke server is not firing and I can’t print past the local TanksBought Var any Solutions?

> boxname.Changed:Connect(function()
> 	local model = nil
> 	
> 	for i, object in pairs(game.Workspace.ItemRoller["Box"..boxname.Value]:GetChildren()) do
> 		
> 		if object:IsA("Model") then
> 			
> 			model = object			
> 		end	
> 	end
> 
> local  TanksBought = game.ReplicatedStorage.GetToolsBought:InvokeServer() ----freezes right here
> 	print("pls") --- never runs 
> 	print(TanksBought) ---never runs 
> 	
> 	for i, Tank in pairs(TanksBought) do
> 		
> 		if Tank == model.Name then 
> 			
> 			script.Parent.Text = "Equipped"
> 		else
> 			script.Parent.Text = "Equip"
> 		end
> 	
> 		
> 		
> 	end
> 	
> 	
> end)
3 Likes

Do you have OnServerInvoke set up on the server for GetToolsBought? If it exists, make sure it’s not erroring / yielding.
https://developer.roblox.com/api-reference/function/RemoteFunction/InvokeServer

If it is set up and you think it’s correct, please post that code.

4 Likes

I’d personally recommend using events, and have the client do an animation when firing the server and wait for the server to fire back.

Because functions can yield and freeze the server, regardless of how you setup your stuff.

1 Like