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

Why is this remote function not affecting the client?

Here is the LocalScript:

local repStorage = game:GetService("ReplicatedStorage")
local eventsFunctions = repStorage:WaitForChild("Events/Functions")
local neededFunction = eventsFunctions:FindFirstChild("RemoteFunction")
local success, message = pcall(function()
	if neededFunction then
		print("arrived at the event") -- this prints
		neededFunction.OnClientInvoke:Connect(function(box)
			print("fired") -- this never prints
			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")
end

Here is the server script:

local remoteFunction = game:GetService("ReplicatedStorage"):FindFirstChild("Events/Functions").RemoteFunction
print("got here") -- this prints
remoteFunction:InvokeClient(player, boxCopy) -- note: player is this: local player = players:GetPlayerFromCharacter(hit.Parent) I do check to see if hit.Parent:FindFirstChild("Humanoid"). players is: game:GetService("Players")				
awardBoxPrize(boxCopy, playerInfo, prize)				
boxCopy:Destroy()

Quick note: All the names and variable assignments are prototypes. This is not how I normally format things. Please refrain from commenting on that kind of stuff. It will be changed when I figure out how to make this work. Thanks!

5 comments

0

By "not affecting" do you mean, it doesn't Invoke the function or there are errors, what is the issue?

0

The print is not printing on line 8 of the local script.

0

My studio crashed and now I am unable to do anymore testing.

0

so I am relying on you guys to help me out

0

lol

1 answer

The problem here is you are trying to connect to a RemoteFunction.

the :Connect function is only used for Events

neededFunction.OnClientInvoke:Connect(function(box) 
-- Should be

neededFunction.OnClientInvoke = function(box)

7 comments

0

OnClientInvoke is not an event?

0

I did not know that

0

thanks I will test this out as soon as studio starts working again

0

It is still not working

0

Yea he's right, that always gets me when using RemoteFunctions.

0

is box able to be passed by the server?

0

to the client?

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