I am creating a game where you stand on different bricks to teleport you to different worlds. when a player touches one of the bricks, i want the chat to say:
could somebody please help me?
I am creating a game where you stand on different bricks to teleport you to different worlds. when a player touches one of the bricks, i want the chat to say:
could somebody please help me?
Hopefully, you have scripting knowledge so this will be easily understandable:
Creating messages in the Chat requires the script to be in a LocalScript in StarterGui, so I do recommend using a Remote/BindableEvent to do this.
Firstly, When a Player touches the brick, make it fire an event. I will call my event 'Event'. If you are using a localscript when the player touches the brick, change the scripting accordingly.
Touching Brick Script (ServerScript):
local event = game.ReplicatedStorage.Event -- Change this to where your BindableEvent is.
script.Parent.OnTouched:connect(function(plr)
event:Fire(plr, gametheywentto) -- Change 'gametheywentto' to the name of the Game you are teleporting them to
-- Rest of teleporting script
end)
(Sorry for any scripting errors, I'll try to correct them if I find any, doing this off the top of my head)
Then, In a 'PlayerLeavingScript' (LocalScript placed in StarterGui), we need to call a function when the Event is Fired.
In my example I will call it PlayerLeft
For this function, you need two arguments: The Player Who Left and The Game they went to
so it will end up as:
function PlayerLeft(plr, game)
-- Rest of the code
end
Now for the most important part: To Create text in the chat, use this function:
game.StarterGui:SetCore("ChatMakeSystemMessage", {}) --Information goes into {}
So then, we create it accordingly:
game.StarterGui:SetCore("ChatMakeSystemMessage", {
Text = ""; -- Change the Text Here
Color = Color3.new(0, 1, 1); -- Cyan is (0, 255 / 255, 255 / 255). Optional, defaults to white: Color3.new(255 / 255, 255 / 255, 243 / 255)
Font = Enum.Font.SourceSans; -- Optional, defaults to Enum.Font.SourceSansBold
FontSize = Enum.FontSize.Size24; -- Optional, defaults to Enum.FontSize.Size18
})
And the function will finish off with:
function PlayerLeft(plr, game)
game.StarterGui:SetCore("ChatMakeSystemMessage", {
Text = plr.Name .. " has left the game to play " .. game;
-- Add Extras if you wish
})
end
then finally, we connect it with the Event being fired:
local event = game.ReplicatedStorage.Event -- again, change
event.Event:connect(function(...)
PlayerLeft(...)
end)
And there we go, hopefully I wrote this correctly.
If you want me to rewrite it, just ask.
For more Information, see this Wiki Article
This discussion is preserved as it was. New answers, comments, and votes are closed.