Creating Unique Movesets Based on the Items a Player has Selected

Hello, everyone.

I’m experimenting with a game idea presented to me by a friend. Roughly explained, the idea is that players can perform various offensive moves to opponents using items. The moves a player can perform depend on what items they have selected.

For example: let’s say a player has two items: a sword and a whip. With just the sword selected, the player can perform two moves: “Slash” and “Thrust.” With only the whip selected, the player can perform just one move, which we’ll call “Crack.” If the player selects both items, however, an entirely new list of moves become available. Let’s say that with both selected, the player links the sword and whip together, and is able to perform a “Spin” move and a Castlevania-style “Lash” move. Note that even when these two items are combined in such a manner, they are still considered two separate items that have been selected together.

My current idea for implementing this is as follows:

  • The player fires a remote event to the server whenever an item in their hotbar is selected / deselected;

  • The server searches for a list of movesets based on the player’s current item combination. The server will then fire a remote event to the client, sending a list of the moves’ names and their associated hotkeys. (If there are no moves for the player’s current selection of items, then the server will return nothing, or perhaps even revert the player’s attempt at selecting / deselecting.)

  • The client, upon receiving the list, removes any previous keybinds and applies new ones for the given movesets, as well as displays the moves’ names and hotkeys on the screen.

The part I am not sure about is actually reacting to the player’s input. Would I create another RemoteEvent that listens to all of a player’s inputs? Where / how would I store the moves’ actual behaviors? Is my current idea any good at all?

I’ve gone as far as setting up the Remotes for this idea; but I’d like to hear your thoughts on this before I go any further and risk wasting time.

1 Like

You should not create a remote event for everyting because it is easy to exploit, create remote only for required things who can’t work without it.

You can simply create a BoolValue for each item / movesets in the player, save them if needed, then when an item is selected it put all the BoolValue list to false and the correct one to true. If it is deselected, it put the BoolValue to false

So in your keybind script, when you press E for example, it will check what BoolValue is true, and fire the correct remote Event.

Example:

Create Bool Value list

game.Players.PlayerAdded:Connect(function(Player)
	
	if not Player:FindFirstChild("ItemsMoves") then
		local Folder = Instance.new("Folder" ,Player)
		Folder.Name = "ItemsMoves"
	end
	
	local Folder = Player:WaitForChild("ItemsMoves" ,10)
	
	local Sword = Instance.new("BoolValue",Folder)
	local Whip = Instance.new("BoolValue",Folder)

	Sword.Name = "Sword"
	Sword.Value = false

	Whip.Name = "Whip"
	Whip.Value = false
end)

Keybind Script

local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local ItemsMoves = Player:WaitForChild("ItemsMoves" ,5)

UIS.InputBegan:Connect(function(key, processed)
	if key.UserInputType == Enum.UserInputType.Keyboard then
		if key.KeyCode == Enum.KeyCode.E and ItemsMoves ~= nil then
			for _,Child in pairs(ItemsMoves:GetChildren())do
				if Child.Value == true then
					local Event = game.ReplicatedStorage.Events:FindFirstChild(Child.Name.. "E")
					if Event ~= nil then
						Event:FireServer()
					end
				end
			end
		end
	end
end)
1 Like