Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to use a simple .chatted script?

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?

1 comment

0

I'm answering this one... 5 minutes xD

2 answers

✓ Accepted answer

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!

7 comments

0

Finished Edits

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.

0

What about putting a script into script builder? I tried it but sadly did not work in the builder

0

He did help me though c;. I cant give credit , only accept answers

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!

0

<3

1

lol thanks bro.

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

4 comments

0

dont work bro

0

This wouldn't work if the player "Abysswalk" hasn't spawned before the script. :P

1

Why is this being downvoted? The code is what the asker requested and runs fine.

0

True, but it is best to use "Good Practices".

This discussion is preserved as it was. New answers, comments, and votes are closed.