Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is this remote function not affecting the client?

Asked by 6 years ago
Edited 6 years ago

Here is the LocalScript:

01local repStorage = game:GetService("ReplicatedStorage")
02local eventsFunctions = repStorage:WaitForChild("Events/Functions")
03local neededFunction = eventsFunctions:FindFirstChild("RemoteFunction")
04local success, message = pcall(function()
05    if neededFunction then
06        print("arrived at the event") -- this prints
07        neededFunction.OnClientInvoke:Connect(function(box)
08            print("fired") -- this never prints
09            if box:IsA("BasePart") then
10                for i = 0.1, 1 do
11                    wait(1)
12                    box.Transparency = i
13                end
14            end
15        end)
16    end
17end)
18if success then
19    print("Happy")
20end

Here is the server script:

1local remoteFunction = game:GetService("ReplicatedStorage"):FindFirstChild("Events/Functions").RemoteFunction
2print("got here") -- this prints
3remoteFunction: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")             
4awardBoxPrize(boxCopy, playerInfo, prize)              
5boxCopy: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!

0
By "not affecting" do you mean, it doesn't Invoke the function or there are errors, what is the issue? climethestair 1663 — 6y
0
The print is not printing on line 8 of the local script. User#21908 42 — 6y
0
My studio crashed and now I am unable to do anymore testing. User#21908 42 — 6y
0
so I am relying on you guys to help me out User#21908 42 — 6y
0
lol User#21908 42 — 6y

1 answer

Log in to vote
1
Answered by
farizarps 132
6 years ago
Edited 6 years ago

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

the :Connect function is only used for Events

1neededFunction.OnClientInvoke:Connect(function(box)
2-- Should be
3 
4neededFunction.OnClientInvoke = function(box)
0
OnClientInvoke is not an event? User#21908 42 — 6y
0
I did not know that User#21908 42 — 6y
0
thanks I will test this out as soon as studio starts working again User#21908 42 — 6y
0
It is still not working User#21908 42 — 6y
View all comments (3 more)
0
Yea he's right, that always gets me when using RemoteFunctions. climethestair 1663 — 6y
0
is box able to be passed by the server? User#21908 42 — 6y
0
to the client? User#21908 42 — 6y
Ad

Answer this question