Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is it possible to make a part tht makes you talk?

Asked by
nd887 0
5 years ago

So, I have barely any Lua experience, but there is a script which google can't find(or I can't), but is it possible to add a script that makes it so it will force a person to talk. This might not be possible, but I want to make sure before I give up. If this is breaking any rules, please comment and I will change(or delete if needed) this post. Thanks, nd887 P.S I want the message to show up in the chat, not just a Bubble.

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

You can use the ChatService to accomplish this (Server Script):

local CS = game:GetService("ChatService")
CS.SpeakerAdded:Connect(function(Speaker)
    script.Parent.Touched:Connect(function(part)
        local player = game.Players:GetPlayerFromCharacter(part.Parent)
        if player then
            if Speaker.Name == player.Name then
                Speaker:SayMessage("Hi", "All")
            end
        end
    end)
end)

The ChatService's SpeakerAdded event returns the speaker who entered the ChatChannel (in this case, that channel is All). From here you can use the SayMessage() method, which requires a string for the speaker to say and a string for the name of the ChatChannel to display the message in. A third, optional parameter is a dictionary that requires a string and a variant value.

0
Am I supposed to copy ChatService while I'm in test mode? nd887 0 — 5y
0
Copy it? What are you trying to do? DeceptiveCaster 3761 — 5y
0
GetService() just returns the service given. It doesn't make a copy nor do you make a copy of the given service. DeceptiveCaster 3761 — 5y
0
Oh, I thought that I would need to copy ChatService. Thanks. nd887 0 — 5y
View all comments (14 more)
0
How long does this take to register because I have another script that teleports you to another place and it takes about 7 seconds to register? nd887 0 — 5y
0
It registers when you hit the part. DeceptiveCaster 3761 — 5y
0
It isn't working? nd887 0 — 5y
0
should I send a video nd887 0 — 5y
0
have you made sure the touch script deactivates when you touch it? if not then it will keep on firing the "Touched" Event over and over until you stop touching it FlabbyBoiii 81 — 5y
0
Why did you nest the event? Also it is Chat, not ChatService? And events don't return? User#24403 69 — 5y
0
"Am I supposed to copy ChatService while I'm in test mode?" i want to go launch nukes at earth now LoganboyInCO 150 — 5y
0
Never really tought of doing this, never knew it was a thing too. Learned something reading a random answer! moo1210 587 — 5y
0
Ok, I fixed the problem. It should now work. Changed "Speaker" to "Speaker.Name". DeceptiveCaster 3761 — 5y
0
also @incapaxx it's ChatService, not Chat. They're two different services. DeceptiveCaster 3761 — 5y
0
@FlabbyBoiii Correct me if I am wrong, but the end) should end it nd887 0 — 5y
0
@RobloxWhizYT do you mean like this local CS = game:GetService("ChatService") CS.SpeakerAdded:Connect(function(Speaker.Name) script.Parent.Touched:Connect(function(part) local player = game.Players:GetPlayerFromCharacter(part.Parent) if player then if Speaker == plr.Name then Speaker:SayMessage("He warned me, but I ignored him. I am now gone.", "All") end end end) nd887 0 — 5y
0
No I do not mean that. Just follow the script. DeceptiveCaster 3761 — 5y
0
@nd887, the end) will end the function but that doesn't mean it can't be touched again and since there's no delay between touches, it will fire the function multiple times before you can stand off of it FlabbyBoiii 81 — 5y
Ad

Answer this question