How to make a message

Hi guys,

I tried a lot of things but it doesn’t work

7 Likes
  • We can’t make whole scripts until you have a error or other conditions

  • You should use Touched Event a Chat Message Scripts there are many of them and lots of tutorial on YouTube also about how to do it

  • Here is a basic script:
    LOCAL FOR EXPLAINATION

local Part = yourPartHere --for eg game.Workspace.Part

Part.Touched:Connect(function (Hit) --Hit is the object that touches it
if Hit.Parent:FindFirstChild("Humanoid") then --Checking if it's a player or not
--Chat send code here
end
end)
1 Like
local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local server = ChatService:AddSpeaker("Server")
server:JoinChannel("All")
server:SetExtraData("NameColor", Color3.fromRGB(255, 255, 255))
server:SetExtraData("ChatColor", Color3.fromRGB(0, 255, 255))


script.Parent.Touched:Connect(function(hit)
    local char = hit:FindFirstAncestorOfClass("Model")

    server:SayMessage(char.Name.." has completed!", "All")
end)
9 Likes

And just for clarification, what game is this?

Is this an obby game? If so, do you have a leaderstat for stage? More information would be useful

1 Like

It is an obby game 1234567890123547

1 Like

Oh, ok. Is there any form of checkpoints?

1 Like

Nope. But I have a game before but its discontinued because of the checkpoints lol.

1 Like

And one final question, does this message only appear when you beat the obby?

1 Like

Yes.

((((((30 characters))))))

1 Like

Ok, so something I’d recommend:

For all of the players, they should have a BoolValue already in their character named “BeatObby”. You can put this BoolValue under StarterCharacterScripts (it’ll be inside the character model). It’ll already be set to false, which is what you want (this will prevent the chat spamming that the player has beat the obby).

Now, for the message script, I would change it to this:

local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local server = ChatService:AddSpeaker("Server")
server:JoinChannel("All")
server:SetExtraData("NameColor", Color3.fromRGB(255, 255, 255))
server:SetExtraData("ChatColor", Color3.fromRGB(0, 255, 255))


script.Parent.Touched:Connect(function(hit)
    local char = hit:FindFirstAncestorOfClass("Model")

    if char:FindFirstChild("BeatObby").Value == false then
        char.BeatObby.Value = true
        server:SayMessage(char.Name.." has completed the obby!", "All")
    end
end)

And then at the beginning of every round, you can loop through all the players and set the BoolValue back to false like this:

for _, v in pairs(game.Players:GetPlayers()) do
    v.Character:WaitForChild("BeatObby").Value = false
end

Hope this helps, and good luck.

6 Likes

Thanks brozzzzzzzzzooooooooooooo

2 Likes

Will be appreciated if you know how to!

1 Like

Not at this moment lol, but If I find out, I’ll tell you a method

1 Like

Ologist#6064

(((((30 chars)))))

Hi there, sorry for the post bump!

I am using this script, so helpful so thank you @OIogist for making it! I’m not using the BoolValue script but just the normal one.

When the player touches it then it spams the message in the chat until they get off the block. Anyway to fix this, if not I’ll just create a script that teleports them away from the block?

how would i make this work for multiple parts? it only works for 1 part.