Hi dev forum! I’m a beginner scripter (been scripting for 2 weeks) but I’m learning quickly!!
You can write your topic however you want, but you need to answer these questions:
1. What do you want to achieve? Keep it simple and clear!
I’m scripting a group/team system for my survival game. Currently I’ve managed for each client to be able to create a server-sided team. a “group”. I’ve also scripted an empty team deleter that removes empty groups. The final step to complete my group system is to create a “send invite to other specific clients” function so that each group leader can invite friends and strangers on their team.
2. What is the issue? Include screenshots / videos if possible!
I can’t figure out how to send data from one client to another specific client. Here is an illustration:
Basically I’ve succeeded for each client that send an invite to reach THE SERVER but from there it ends, I can’t reach the specific client. Here is my local script for the team/group leader:
*Survivors is the neutral auto-assignable team on the server. All players that are not in Survivors have either created or joined a private team.
local RS = game:GetService("ReplicatedStorage")
local Frame = script.Parent
local players = game:GetService("Players")
local teams = game:GetService("Teams")
local playerList = players:GetPlayers()
local positionTable = {UDim2.new(0.154, 0, 0.054, 0), UDim2.new(0.154, 0, 0.180, 0), UDim2.new(0.154, 0, 0.310, 0),
UDim2.new(0.154, 0, 0.440, 0), UDim2.new(0.154, 0, 0.570, 0)
}
function generateNames() -- generates a full list of all players on the server
for i, v in pairs(playerList) do
local localplayer = players.LocalPlayer
local playerButton = Instance.new("TextButton")
playerButton.Parent = Frame
playerButton.Text = (v.Name)
playerButton.Position = positionTable[i]
playerButton.Size = UDim2.new(0, 69, 0, 20)
playerButton.MouseButton1Up:Connect(function()
if localplayer.Team == teams.Survivors then -- checks if the client is on the neutral team "Survivors". If it is then he/she has to create a group.
print("You need to create a group")
else
RS:WaitForChild("SendInvite"):FireServer(v, localplayer) -- sends data to server, localplayer(the sender), v(the reciever)
print("Invite sent")
end
end)
end
end
Frame.SendMessage.MouseButton1Up:Connect(generateNames) -- ignore this it's just a button to generate the playerlist
Here is the server sided script that runs the remoteEvent:
local RS = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local playerList = players:GetPlayers()
local teams = game:GetService("Teams")
RS.SendInvite.OnServerEvent:Connect(function(localplayer, v)
print("server recieved")
print(localplayer) -- just checks to see if "sender" input has reached the server
print(v) -- just checks to see if "specified reciever" input has reached the server
wait(0.5)
RS.sendInfoToclient:FireClient(v, localplayer) -- tries to port the data to a specific client, specifically "v". localplayer is also sent trough to identify the team later
local newbutton = Instance.new("TextButton")
newbutton.Parent = v.PlayerGui.ScreenGui -- places the "accept button" in the specified clients ui. The recievers ui basically.
newbutton.Text = ("Accept invite")
newbutton.Position = UDim2.new(0, 0, 0, 0)
newbutton.Visible = true
newbutton.MouseButton1Up:Connect(function() -- if player v clicks the button the following code will check:
if v.Team == teams.Survivors then -- checks if player v is in the "neutral" team which is Survivors. if it is then player v can join the localplayers team
v.Team = localplayer.Team -- places the player v (the client that info has been sent to) in the localplayers team (the client that sent the info)
end
end)
end)
I don't know if any of that makes sense or if i've pasted the code correctly.
**3. **What solutions have you tried so far?** Did you look for solutions on the Developer Hub?**
I've been in studio for hours, watched multible youtube vids and have also read a number of dev topics related to this issue.
I feel like this is an eazy thing to script but I'm totally lost. Any suggestions/ ideas on how to do this is highly appreciated!! :smile: