Basically I need to get a value from a dictionary, which matches with the Team’s name that the player is currently on.
print(Player.Team.Name)
works perfectly fine, but even when using tostring()
it does not seem to get the value from the dictionary and is returning nil
instead.
Here is the script:
local Badges = {
["SEK"] = "rbxassetid://13360522826",
["Polizei"] = "rbxassetid://13610655205",
["Autobahnpolizei"] = "rbxassetid://13610684536",
["Feuerwehr"] = "rbxassetid://13610749945",
["Rettungsdienst"] = "rbxassetid://13610764116",
["THW"] = "rbxassetid://13610764116",
["Zoll"] = "rbxassetid://13610809138"
}
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local FunkFolder = ReplicatedStorage:FindFirstChild("Funk")
local MessageEvent = FunkFolder:WaitForChild("Message")
local teams = {"Autobahnpolizei", "Feuerwehr", "Polizei", "Rettungsdienst", "SEK", "THW", "Zoll"}
local TextService = game:GetService("TextService")
local function FilterMessage(MessageToFilter, UserID)
TextService:FilterStringAsync(MessageToFilter, UserID, Enum.TextFilterContext.PublicChat)
end
local EventFolder = ReplicatedStorage:WaitForChild("Funk")
local MessageEvent = EventFolder:FindFirstChild("Message")
MessageEvent.OnServerEvent:Connect(function(Player, Channel, Message)
print("Message received by server")
print(Badges[tostring(Player.Team.Name)])
MessageEvent:FireAllClients(Player, Channel, FilterMessage(Message, Player.UserId), Badges[tostring(Player.Team.Name)])
end)
Any help is appreciated!