Attempt to call a Instance Value

A script here is supposed to change the value of a num value in replicated storage. When a player clicks a gui button a remote event fires which activates the script:

local event2 = game:GetService("ReplicatedStorage").NumUp
function onEvent2(player)
	
local count = game.ReplicatedStorage.GunNum
	if count.Value > 5 then 
		count.Value = count.Value + 1
	
	else
		count.Value = 0
	end
end

event2.OnServerEvent:Connect(event2)

Yet I keep getting the error message Attempt to call a instance value on the server side. I’ve tried debugging it yet I still don’t know what the issue is…

1 Like

You sent the object to the connection, not the function.

event2.OnServerEvent:Connect(onEvent2)
2 Likes

Hah. Thanks. Didn’t even notice that.