Hello!
My script that sends a welcome message to the player in the chat isn’t working. What did I do wrong?
All help is appreciated! Thanks!
Hello!
My script that sends a welcome message to the player in the chat isn’t working. What did I do wrong?
All help is appreciated! Thanks!
Hi @Yawyawalpaca333!
When using the PlayerAdded event it will pass data from this event to the function you have connected it to, this is important so your function can take the data and let it be used. When creating the function make sure you add a player
parameter to be used later in your code.
The other issue I see is when you do player.name
you have two problems. First, you’ve made this into a string so the engine sees this as a simple string rather than a property to reference from. And second you should have name with a capital N so that it properly references the property.
--Code snippets to be applied to your code
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(newPlayer)
print("Everyone welcome to the server "..newPlayer.Name)
end)
I’ve had a long hiatus from the platform so apologies if other issues appear, these are just some things I picked up when looking over your code.
Good luck, let me know how things go!
Hello!
If the player.name
is in the string it will return “player.name”, otherwise if it was player.Name.."!"
it would return “(playersname)!” e. g. “roplayer52!”. Also I reccomend using display names instead of default player names to make the text not huge and not massive either.
Your code should look like:
-- Access players
local plrs = game.Players
local gui = game.StarterGui
-- Run code everytime
plrs.PlayerAdded:Connect(function(v) -- v is the player that joined
gui:SetCore("ChatMakeSystemMessage", { -- create a new chat message
Text = "Welcome to Treat Tycoon "..v.DisplayName.."!", -- text for the welcome message
Color = Color3.new(255, 221, 0), -- color for the welcome message
Font = Enum.Font.SourceSansBold, -- font for the welcome message
FontSize = Enum.FontSize.Size24 -- font size for the welcome message
}) -- end of core
end)
Thanks for mentioning display names, highly recommend you swap over to this.
No problem, have a great day! Personally I like using displaynames to keep the text short.
Maybe also replace Color3.new with Color3.FromRGB because if it used Color3.new, it would look like this:
Color = Color3.new(1, 0.866667, 0)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.