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

How is a different value being passed through?

Asked by 8 years ago

Okay, so this one is a little bit harder for me to understand, but I think it's beyond broken.. :( Anyways, I'm using RemoteFunctions (heard those are bad, oh well.) to make an ingame friend system.. It's working flawlessly until I make the gui to ask to be friends... If I click no. I get a whole load of errors..

P.S I tried to explain as best as I could the first time.

Output for Server:

[SERVER] Player1 Player2 Player1

Output for Client that was asked:

07:20:57.157 - Players.Player2.PlayerGui.PlayerHUD.bg.LocalScript:32: attempt to concatenate local 'action' (a userdata value) 07:20:57.159 - Script 'Players.Player1.PlayerGui.PlayerHUD.bg.LocalScript', Line 26 07:20:57.161 - Stack End

Output for Client that was asking:

07:20:57.082 - Players.Player2.PlayerGui.PlayerHUD.bg.LocalScript:32: attempt to concatenate local 'action' (a userdata value) 07:20:57.093 - Stack Begin 07:20:57.094 - Script 'Players.Player2.PlayerGui.PlayerHUD.bg.LocalScript', Line 32 07:20:57.095 - Stack End

LocalScript:

local requestFriend = game.ReplicatedStorage.CrossConnections.Friends.RequestFriend
local requestResponse = game.ReplicatedStorage.CrossConnections.Friends.RequestResponse

function requestFriend.OnClientInvoke(askingPlayer)
    friendRequest.Question.Text = askingPlayer.Name .. " wants to be friends. Do you accept?"
    friendRequest.Visible = true

    friendRequest.Yes.MouseButton1Click:connect(function()
        friendRequest.Visible = false
        addFriend:InvokeServer(player, askingPlayer)
        requestResponse:InvokeServer(askingPlayer, player, "accepted")
    end)

    friendRequest.No.MouseButton1Click:connect(function()
        friendRequest.Visible = false
        requestResponse:InvokeServer(askingPlayer, player, "declined")
    end)
end

function requestResponse.OnClientInvoke(declinedPlayer, action)
    _G.output(declinedPlayer, action)
    requestResponseFrame.Response.Text = declinedPlayer.Name .. action .. " your friend request."
    requestResponseFrame.Visible = true
    wait(3)
    requestResponseFrame.Visible = false
end

RPG_Core

function requestFriend.OnServerInvoke(player, newFriendName)
    requestFriend:InvokeClient(game.Players:FindFirstChild(newFriendName), player)
end

function requestResponse.OnServerInvoke(player, otherPlayer, action)
    _G.output(player.Name, otherPlayer.Name, action)
    requestResponse:InvokeClient(otherPlayer, player, action)
end

function addFriend.OnServerInvoke(player, newFriend)
    modFriendDataStore:AddFriend(player, newFriend)
    modFriendDataStore:AddFriend(newFriend, player)
end

1 answer

Log in to vote
0
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
8 years ago

RemoteEvents automatically sends the LocalPlayer of the client that invoked the server as the first argument. Then After that, your tuple arguments will appear.

Local Script

local remoteEvent = game.ReplicatedStorage.RemoteEvent

remoteEvent:FireServer(...)

Server Script

local remoteEvent = game.ReplicatedStorage.RemoteEvent

remoteEvent.OnServerInvoke:connect(function(player, ...)

end)

You will have to account for this extra parameter server side, or else your arguments will appear to be shifted by one place.

Ad

Answer this question