Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Welcome script not connecting and or won't display in chat, how to fix?

I've put the script in a local script since StarterGui:SetCore must be called from a local script and I've also put it in the StarterGui but it still doesn't work. I know the MakeChat function works, but when I add the function that connects it to a player joining it stops and doesn't print the text in chat.

function MakeChat(Msg,Color)
Color=Color or Color3.new(0,1,0)
game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{
Text = Msg;
Color = Color;
Font = Enum.Font.SourceSansBold;
FontSize = Enum.FontSize.Size18;
})
end
function onPlayerEntered(nP)
MakeChat("[SERVER]: Welcome, "..nP.Name.."!", Color3.new(12,130,22));
end
game.Players.PlayerAdded:connect(onPlayerEntered)

Any clue on how to fix?

2 comments

0

have you tried using a variable for the msg or simple test text? Could be the way its formatted. Is it giving an error?

0

no error, nothing in output or anything

1 answer

✓ Accepted answer

You could use a RemoteEvent to communicate between the server and client, which allows for you to manipulate the StarterGui from the server.

Server script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Event = ReplicatedStorage:WaitForChild("RemoteEvent")

function onPlayerEntered(nP)
    Event:FireClient(nP,"[SERVER]: Welcome, "..nP.Name.."!", Color3.new(12,130,22))
end
game.Players.PlayerAdded:connect(onPlayerEntered)

LocalScript:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage:WaitForChild("RemoteEvent")
  
Event.OnClientEvent:Connect(function(msg,color)
    game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{
	    Text = msg;
	    Color = color or Color3.new(0,1,0);
	    Font = Enum.Font.SourceSansBold;
	    FontSize = Enum.FontSize.Size18;
    })
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.