So I’m making a team based game and I want to find out how to make a chat message that says which team won.
I tried to right this script in a starterplayer script to make a chat message and im having troubles. Ill take any help I can get. (an example of what I want is in doomspire brickbattle how it displays a server message after a team wins)
So even without reading your script, im pretty sure you want to put it under server script storage rather then starter player script, as otherwise it would put the script under all players.
After reading your code, I gotta say i raelly aint that familier with chatmakesystemmessage, but how far does the code go? (btw move it to anywhere but starter player script, and if its a local script, then make it a server script)
In a LocalScript:
local players = game:GetService("Players")
local startGui = game:GetService("StarterGui")
local teams = game:GetService("Teams")
local button = [Your button]
local localPlayer = players.LocalPlayer
button.Touched:Connect(function(hitObj)
local player = players:GetPlayerFromCharacter(hitObj.Parent)
if (player and player == localPlayer) then
local plrTeam = player.Team
startGui:SetCore("ChatMakeSystemMessage", {Text = plrTeam.Name .. " won!", Color3 = Color3.fromRGB(plrTeam.TeamColor.Color), Font = Enum.Font.FredokaOne, 10})
end
end)
I fixed your code and cleaned it up a little. I would take a second to review it and learn how it works, let me know if you have any questions.
Source: https://developer.roblox.com/en-us/api-reference/function/StarterGui/SetCore
StarterGui:SetCore()
can only be called from the client.
You’ll also need to check that player == localplayer
as Touched
will fire for each client. That or player.Team == localplayer.Team
.