The problem here is that you are using “target” as the first argument, which will be the client that invoked the RemoteFunction, add player, before the target argument
ReplicatedStorage.GetOtherPlayerData.OnServerInvoke = function(player, target)
return data[target.UserId]
end
Yes, that is because they are sending a string, not a player through the remote, since the remote does .UserId, it would return nil since .UserId wouldn’t be valid of a string
ReplicatedStorage.GetOtherPlayerData.OnServerInvoke = function(player, target)
return data[target.UserId]
end
Client:
for i,textbuttons in pairs(servermenu:GetChildren()) do
if textbuttons:IsA("TextButton") and textbuttons.Name ~= "LeaveServer" then
textbuttons.Activated:Connect(function()
if textbuttons.Text ~= "" then
local targetPlayer = game.Players:FindFirstChild(textbuttons.Text)
local clickedplayerdata = getpdata:InvokeServer(targetPlayer)
if clickedplayerdata then
playergui.MainGui.PlayerStatsInformation.Visible = true
playergui.MainGui.PlayerStatsInformation.Playername.Text = textbuttons.Text
playergui.MainGui.PlayerStatsInformation.Playerlvl.Text = "Lv. " .. clickedplayerdata.Level
for i,unitsselected in pairs(clickedplayerdata.SelectedTowers) do
local unitsmodel = game.ReplicatedStorage.Units:FindFirstChild(unitsselected):Clone()
local unitstats = require(unitsmodel:WaitForChild("Stats"))
local oldbutton = playergui.MainGui.PlayerStatsInformation.EquippedUnit:FindFirstChild(unitsselected)
if oldbutton then
oldbutton:Destroy()
end
local buttongui = playergui.MainGui.PlayerStatsInformation.EquippedUnit.Layout:Clone()
buttongui.Name = unitsselected
unitsmodel.Parent = buttongui.ViewportFrame.WorldModel
buttongui.Visible = true
buttongui.Parent = playergui.MainGui.PlayerStatsInformation.EquippedUnit
end
end
end
end)
end
end