I wanted to make a part that when a player touched it will send a message on the chat with player name in it like “Username has completed!”
I tried a lot of things but it doesn’t work. I have been searching for over 1 year of this but I did not find the perfect one. I searched Google, YouTube, and more but still.
I’m new to Roblox scripting so if you know how to make a script that can do that, please let me know and I’ll very much appreciate it.
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)
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
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?