I want to make a Gui that changes an entire teams Cash/Point Value
I have already made this Gui work for certain players with the help of the dev forum, but now I want to update it so you can add to a whole team’s cash/point value
What is the issue?
I am having a lot of trouble doing this and I just don’t think I am going in the right direction.
What solutions have you tried so far?
I have Manipulated my Main Value script to try and add a team part, I have made a 2nd RemoteEvent,
I have even changed the script inside of the Give button but it just won’t work. Which is why I decided to make this post, and here is my original post (that was solved) on trying to make it players only: Change A Player's Cash/Point Value From A Gui
Anyways, thanks for reading and if you can help please do so, I will take any advice lol
Could you try using :GetPlayers(), then write a IF statement regarding if the player is apart of the team, and if so give them the commends. I’m not the best at scripting but I might be able to help with scripting.
Yea my code is actually like that, and I have two scripts in ServerScriptService that check if the events have been fired one checks if only the Player Name part was used and one checks for the team
--team only script
game.ReplicatedStorage.TeamEvent.OnServerEvent:Connect(function(player, team, Values)
for i = 1, #player do
if #player.Team.Name == ""..team then
local PlayerToGive = game.Players:FindFirstChild(Values[2])
PlayerToGive.leaderstats.Commends.Value += Values[1]
end
end
end)
--Player only script (works)
game.ReplicatedStorage.AdminEvent.OnServerEvent:Connect(function(player, Values)
local PlayerToGive = game.Players:FindFirstChild(Values[2])
PlayerToGive.leaderstats.Commends.Value += Values[1]
end)
function onClick()
local FindName = script.Parent.Parent.PlayerName.Text
local FindTeam = script.Parent.Parent.TeamName.Text
script.Parent.Parent.CurrentPlayer.Value = tostring(FindName)
script.Parent.Parent.CurrentTeam.Value = tostring(FindTeam)
local FindAmount = script.Parent.Parent.AmountOfPoints.Text
script.Parent.Parent.Points.Value = tonumber(FindAmount)
local team = script.Parent.Parent.CurrentTeam.Value
local Values = {
script.Parent.Parent.Points.Value,
script.Parent.Parent.CurrentPlayer.Value
}
game.ReplicatedStorage.AdminEvent:FireServer(Values) --This is a remote event I created which is transferring the table of values.
game.ReplicatedStorage.TeamEvent:FireServer(team, Values)
end
script.Parent.MouseButton1Click:Connect(onClick)
Could you try using this method? I haven’t tested it but it might work. ( I didn’t write this in studio so its messy )
Players = game:GetService("Players")
game.ReplicatedStorage.TeamEvent.OnServerEvent:Connect(function(player, team, Values)
for i, player in pairs(Players:GetPlayers()) do
if player.Team == team then
--give commends
end
end
end)
Ok I tried it but it didn’t work and I know why, When I put in a team and leave the “Player Name” blank it says in Output “ServerScriptService.Commend System Giver:3: attempt to index nil with ‘leaderstats’)”
because I there was nothing in the Textbox, Idk what to do about that. (at least that’s why I think it happened) Code:
Players = game:GetService("Players")
game.ReplicatedStorage.TeamEvent.OnServerEvent:Connect(function(player, team, Values)
for i, player in pairs(Players:GetPlayers()) do
if player.Team == team then
Players.leaderstats.Commends.Value += Values[1]
end
end
end)
Same error “ServerScriptService.Commend System Giver:3: attempt to index nil with ‘leaderstats’”
But I added it because it will probably fix some other bug or something
Players = game:GetService("Players")
game.ReplicatedStorage.TeamEvent.OnServerEvent:Connect(function(plr, team, Values)
for i, player in pairs(Players:GetPlayers()) do
if player.TeamColor == (Place the team's color here) then
players.leaderstats.Commends.Value = players.leaderstats.Commends.Value + 1
end
end
end)
if player.TeamColor == (Place the team’s color here)
Simply change “player.TeamColor” to “player.Team.Name” add the parameter ‘team’ behind the == and make it pass on the team name which you want to change the values of.
It’s been a long time since I last replied here, but I think that the error comes from the give money to a single-player script rather than the give money to a entire team-script. Add money to the team and check if the if the team script added the commends by checking “Folder” > “Commends” in the explorer ( Example below)