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

How to use a simple .chatted script?

Asked by 8 years ago
game.Players.Abysswalk.Chatted:connect(function(msg)
    if msg == "Spread" then
        -- right here I tried to make my humanoid jump but it wont work
end
end)

I put the above piece into a script im working on and it dont work. Well, Im pretty sure i didnt do something right lol

I asked this question before but i messed up lol

any help?

0
I'm answering this one... 5 minutes xD User#11440 120 — 8y

2 answers

Log in to vote
0
Answered by 8 years ago

This should all be in a regular script in ServerScript service

Now there are a few problems with your script. First of all, this would instantly error if the player "Abysswalk" wasn't in the game when the script loaded. So in order to get this to never error I would suggest the PlayerAdded event. Like so,

game.Players.PlayerAdded:connect(function(plr)
    plr.Chatted:connect(function(msg)
         if msg == "Spread" then
                 -- right here I tried to make my humanoid jump but it wont work
        end
    end)
end)

Okay, now when any player joins the game and chats the Message "Spread" the commented area will activate. Now, if you're trying to make the character Jump when this is Chatted then you would get the character from the player using plr.Character.After that, you would find the Humanoid of the character and activate the Jump property. Like so,

game.Players.PlayerAdded:connect(function(plr)
    plr.Chatted:connect(function(msg)
         if msg == "Spread" then
                plr.Character:FindFirstChild("Humanoid").Jump = true -- makes Player's character jump.
        end
    end)
end)

That should work BUT, if you want it to only work for you, you would have to check to see if the player's name was the same as yours. And because when testing on Roblox Studioyour characters name is always just "Player" you should also add that for the check as well. Like so,

game.Players.PlayerAdded:connect(function(plr)
    plr.Chatted:connect(function(msg)
         if msg == "Spread" then
            if plr.Name == "Abysswalk" or plr.Name == "Player"  then -- also checks name
                plr.Character:FindFirstChild("Humanoid").Jump = true 
            end
        end
    end)
end)

Hope that helped! Good Luck!

0
~~Finished Edits~~ User#11440 120 — 8y
0
I can see how much effort you put into my man, I like that ^^. So if I would put this script into my game and run it solo it would work. abysswalk 10 — 8y
0
What about putting a script into script builder? I tried it but sadly did not work in the builder abysswalk 10 — 8y
0
He did help me though c;. I cant give credit , only accept answers abysswalk 10 — 8y
View all comments (3 more)
0
I edited one more time but this is a great method and I this "Would" work. Trust me xD Make sure to put it in server script service. But if this doesn't work for some reason. Explain why if you can. :P Good luck! User#11440 120 — 8y
0
<3 User#11440 120 — 8y
1
lol thanks bro. abysswalk 10 — 8y
Ad
Log in to vote
0
Answered by
Prioxis 673 Moderation Voter
8 years ago

The wiki is an amazing place

.chatted with examples

chat commands

local char = game.Players:FindFirstChild("Abysswalk").Character
game.Players.Abysswalk.Chatted:connect(function(msg)
    if msg == "Spread" then
        char.Humanoid.Jump = true
end
end)

try that it might just work

also make sure if your testing it online if it doesn't work it might need to be a local script

0
dont work bro abysswalk 10 — 8y
0
This wouldn't work if the player "Abysswalk" hasn't spawned before the script. :P User#11440 120 — 8y
1
Why is this being downvoted? The code is what the asker requested and runs fine. LightningRoMan 100 — 8y
0
True, but it is best to use "Good Practices". User#11440 120 — 8y

Answer this question