Scripting Help!

Hello! I need help with something! I am creating something where you can say a prompt such as :prompt1! What it will do is make the player who said it say a certain line! Its for my cafe training center so the trainer can just use the commands to say what they need? I have some script but i dont know how to change the message?

game.Players.PlayerAdded:connect(function(player)
	player.Chatted:connect(function(msg)
		if msg == ":prompt1" then
		end
	end)	
end)

Your code runs when a new player is added. Consider removing “game.players.playeradded:connect(function(player)” as it is unnecessary.

Second, you have no code to run when the player chats :prompt1, therefore, it does not do anything. Maybe you could do a print(“Prompt1 Chatted!”) to check if it is working.

Finally, is this a local or server script?

1 Like

It is a server script and yes it has no code because i have no idea how to make the player say what they need too!

Now, having this on a server script isn’t bad, but it’s way easier to do this on a local script. I would make a RemoteEvent and fire it when the message is sent. Check the example code to help you.

REFERENCES:

1 Like

Ok but i dont struggle with any of that im just very unsure how to get it to say a sentence when they use the commands.

I am kinda confused about what “line” are we talking about when the statement is true? The player should say something in chat or something?

1 Like

Ok so when they say the command it needs to change the text to like a different sentence! Its for a cafe training center. So when they say :prompt1 itll say something like Hi! Welcome to training!

Would you like an example of what i mean?

Here you go!

1 Like

Thank you! I honestly dont know how i would implement that into the thingy LOL! Im still pretty noob at scripting lols.

I think it should work if you just fire a RemoteEvent, then receive it on a server script. Then, on the server script, you can then just paste the code in that post I linked earlier to run when the function is received. Of course, you can scout through the code and change what the message should say.