I’m working on a title system. But there seems to be a big issue that I currently have.
Player1 Screen that has a Title equipped:
Player2 Screen that doesn’t have a Title equipped:
script:
TextChatService.OnIncomingMessage = function(msg:TextChatMessage)
local props = Instance.new("TextChatMessageProperties")
if msg.TextSource then
local plr = game.Players:GetPlayerByUserId(msg.TextSource.UserId)
local Title = GetData:InvokeServer(plr)["TitleStats"]["Equipped"]
local Stats = TitleStats[Title]
print(Title)
if Stats then
props.PrefixText = [[<font color="]]..convert(Stats["Color"].Keypoints[1].Value)..[[">]].."["..Stats["Text"].."]"..[[</font> ]]..msg.PrefixText
end
end
return props
end
Nothing to worry then! Does your server script for getting data happen to look like this:
GetData.OnServerInvoke = function(Player: Player)
-- Data stuff for Player
end
In your case where you pass in the plr who might not be your local player, you’ll need to adjust it to look like this instead:
GetData.OnServerInvoke = function(SenderPlayer: Player, Player: Player)
-- Data stuff for Player, not SenderPlayer
end
Personally I’d expose the current Equipped title as an attribute instead of sending that GetData fetch. That would change your message script into this instead:
TextChatService.OnIncomingMessage = function(msg:TextChatMessage)
local props = Instance.new("TextChatMessageProperties")
if msg.TextSource then
local plr = game.Players:GetPlayerByUserId(msg.TextSource.UserId)
local Title = plr:GetAttribute("EquippedTitle")
local Stats = TitleStats[Title]
print(Title)
if Stats then
props.PrefixText = [[<font color="]]..convert(Stats["Color"].Keypoints[1].Value)..[[">]].."["..Stats["Text"].."]"..[[</font> ]]..msg.PrefixText
end
end
return props
end
Hope that solves your problem but if it doesn’t let me know