Chat events help

Does anybody know how I would go about making chatted events in which 4 people have to chat something in order for the script to run? Kinda like a collective chatted event system.

For example:

Player 1 - Chats
Player 2 - Doesn’t Chat
Player 3 - Chats
Player 4 - Doesn’t Chat

  • Script Doesn’t Run -

If this doesn’t make sense, please let me know so I can elaborate more. Thank you!

First thing I can ask is; `What have you tried so far?', and an elaboration would help also.

Well, thats the thing. I don’t know where to start.

Basically, I’m trying to make a chatted event system in which 4 players must speak a certain chat for a certain outcome.

So basically ALL 4 players have to speak a certain chat for something to happen.

I really don’t know where to go from, I’ve tried researching this – nothing.

So what I’ve inferred from this and the above; you want something to happen when 4 users chat something in chronological order?

That would be the idea.

I don’t know where to start at all.

Put each user into an array, count them in order, when one user chats check the state for the user that has to chat, if they match then pass, else do something different

1 Like

Thank you!!! I’ll try this. Have an amazing day.

local Rodux = require(path.to.rodux);
local ReducerExample = function(state, action)
    state = state or {};
    if action.type == "userChatted" then
        if state[action.payload.partyId].userToChat == action.payload.user then
            return {
                [action.payload.partyId]={
                    users = state[action.payload.partyId].users,
                    userToChat = state[action.payload.partyId].users[action.payload.user+1],
                }
            }
        end
    end
    return state;
end

local store = Rodux.Store.new(ReducerExample, {}, {Rodux.loggerMiddleware})
store:dispatch({
    type = "userChatted",
    payload = {
        partyId = 1,
        user = 1,
    }
})

I haven’t actually tested this by the way

1 Like

Is that an external module if yes what does it do?

https://roblox.github.io/rodux

It’s based on javascript’s Redux state manager

image
it seems to register my action anyway

Oh well, it’s not working for me in Roblox Studio – but thank you anyways.

I really appreciate your help!:slight_smile:

Because you actually need to have rodux in your project

Ah, alright. Will try ASAP … Thank you

Changed it a bit to remove bugs

local Rodux = require(script.Parent:WaitForChild("rodux", 50));
local ReducerExample = function(state, action)
	state = state or {};
	if action.type == "userChatted" then
		local party = state[action.payload.partyId]
		if party then
			if party.userToChat == action.payload.user then
				return {
					[action.payload.partyId]={
						users = state[action.payload.partyId].users,
						userToChat = state[action.payload.partyId].users[action.payload.user+1],
					}
				}
			end
		end
	end
	return state;
end

local store = Rodux.Store.new(ReducerExample, {[1]={users={1, 2, 3, 4}, userToChat=1}}, {Rodux.loggerMiddleware})
store:dispatch({
	type = "userChatted",
	payload = {
		partyId = 0123,
		user = 1,
	}
})
store.changed:connect(function(p, n)
	if p == n then return print("State wasn't changed") end
	return print(p, n)
end)

Alright! Should I move Rodux out of Replicated Storage and make the script it’s parent? Or…

Anywhere, as long as the script can see it, and also I’m doing this on the client right now, but i’ll move it to the server when you get setup

Alright, thanks so much. I’m going to try again.

Did you get it working in the end?