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

RemoteFunctions involving gui's not working?

Asked by 5 years ago

I've never used Remote Function and this script isn't working script in SSS

game.Players.PlayerAdded:Connect(function()
    game:GetService("ReplicatedStorage").fui:InvokeClient()
end)

local script in startergui

local function gi()
    script.Parent.Text = "AAAAAAAAAAAAAA"
end
game:GetService("ReplicatedStorage").fui.OnClientInvoke = gi

this probably looks terrible

1 answer

Log in to vote
0
Answered by 5 years ago

This is because you did not specify the client to invoke to. The first argument to RemoteFunction:InvokeClient() is the Player object for the server to invoke. Without it, how will the server know which client? You also should use RemoteEvents for those things, as RemoteFunctions are for two way communication and for returning things. You weren't returning anything.

game:GetService("Players").PlayerAdded:Connect(function(plr) -- passes player parameter
    game:GetService("ReplicatedStorage").fui:FireClient(plr) -- player to fire to
end)

Client:

-- I have changed from a RemoteFunction to a RemoteEvent!

local function gi()
    script.Parent.Text = "AAAAAAAAAAAAAA"
end
game:GetService("ReplicatedStorage").fui.OnClientEvent:Connect(gi)
Ad

Answer this question