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 5 years ago
Edited 5 years ago

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!

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

1 answer

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

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)
0
OnClientInvoke is not an event? User#21908 42 — 5y
0
I did not know that User#21908 42 — 5y
0
thanks I will test this out as soon as studio starts working again User#21908 42 — 5y
0
It is still not working User#21908 42 — 5y
View all comments (3 more)
0
Yea he's right, that always gets me when using RemoteFunctions. climethestair 1663 — 5y
0
is box able to be passed by the server? User#21908 42 — 5y
0
to the client? User#21908 42 — 5y
Ad

Answer this question