How do I make text have a player name in it? I'm trying to make a script that says something like "(name) won!" but it does nothing. Here's the code I have.
local Players = game:GetService("Players")
local part = script.Parent
local player = Players:GetPlayerFromCharacter(part.Parent)
local debounce = false
game.Workspace.epicBrick.Touched:Connect(function(hit)
if not debounce then
debounce = true
bc = BrickColor.new("New Yeller")
game.StarterGui:SetCore("ChatMakeSystemMessage", {
Text = player.Name .. " won!"; --error here?
Font = Enum.Font.SourceSansBold;
Color = bc.Color;
FontSize = Enum.FontSize.Size32;
})
wait(5)
debounce = false
end
end)
When I playtest the game and touch the brick called "epicBrick", nothing happens. When I remove "player.Name" from the error line, it types " won!" in chat, but without the player name.
Edit: Changed to this because it could be better than the last version to see issues. I still can't figure it out though. New Version:
local character = game.Workspace.Player
local player = game.Players:GetPlayerFromCharacter(character)
local debounce = false
game.Workspace.epicBrick.Touched:Connect(function(hit)
if not debounce then
debounce = true
bc = BrickColor.new("New Yeller")
game.StarterGui:SetCore("ChatMakeSystemMessage", {
Text= player.Name .." won!"; --error here?
Font = Enum.Font.SourceSansBold;
Color = bc.Color;
FontSize = Enum.FontSize.Size32;
})
wait(5)
debounce = false
end
end)

1 comment
Your referencing startergui statergui is what gets cloned to player so on line 9 change startergui to playergui