I have an event that fires when someone touches a box. After the event is fired I reward them with a prize and destroy the box. The problem is that in the server the box disappears after a whole second. In order to fix that issue I created a remote function that would fade the box out on the client side. Here is the script:
print("got here") -- this prints
remoteFunction:InvokeClient(plr, box)
box:Destroy()
and here is the local script:
local replicatedStorage = game:GetService("ReplicatedStorage")
local eventsFunctions = replicatedStorage:WaitForChild("Events/Functions")
local neededFunction = eventsFunctions:FindFirstChild("RemoteFunction")
local success, message = pcall(function()
if neededFunction then
neededFunction.OnServerInvoke = function(plr, box)
print("fired") -- this does not print
if box:IsA("BasePart") then
for i = 0.1, 1 do
wait(1)
box.Transparency = i
end
end
end
end
end)
if success then
print("Happy")--this prints
end
A few notes: The local script is placed inside of StarterPlayerScripts. There is only one function inside of Events/Functions. The box does not fade out. The server script works fine. Thanks!

3 comments
If you have any comments on better methods feel free to post them.
I just realized that the for loop would not work anyway. However, the remote function problem still needs addressed.
Thanks to incapaz for the solution. OnClientInvoke was needed.