I cant make the client print the skillSet name

i cant seem to make this work, i have been trying to make it so if you press 1, 2, or 3(if it exists) to print the skill name but it wont work :
–PathChoosing (Client)

local PathRemote = game.ReplicatedStorage.Remotes:WaitForChild("PathRemote")
local pathModule = require(game.ReplicatedStorage.PathChoice.PathModule)

local skillFunction = game.ReplicatedStorage.Remotes:WaitForChild("SkillUsage")

PathRemote.OnClientEvent:Connect(function(pathData)
	if pathData and pathData.Path then
		print("Received Path Data:", pathData.Path)
	end

	local playerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
	local pathFrame = playerGui:WaitForChild("PathSkillChoice"):WaitForChild("PathFrame")

	for _, path in pairs(pathModule) do
		print("Path:", path.Path)

		for i, skill in ipairs(path.PathSkills) do
			local cloneTemp = script.SkillName:Clone()
			cloneTemp.Name = skill.Name
			cloneTemp.Text = skill.Name
			cloneTemp.Parent = pathFrame
			cloneTemp.Position = UDim2.new(0, 0, 0, i * 21)
		end
	end
end)

local function skillUsage(skillIndex)
	for _, path in pairs(pathModule) do
		print("Checking path:", path.Path)

		if path.PathSkills then
			print("PathSkills Count:", #path.PathSkills)

			for i, skill in ipairs(path.PathSkills) do
				print("Index:", i, "Skill Name:", skill.Name)
			end

			local skill = path.PathSkills[skillIndex]
			if skill then
				print("Using Skill:", skill.Name)
				skillFunction:InvokeServer(skill.Name)
				return skill.Name
			end
		end
	end
	print("No skill found for index:", skillIndex)
	return nil
end


local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(i, g)
	if not g then
		local keyMap = {
			[Enum.KeyCode.One] = 1,
			[Enum.KeyCode.Two] = 2,
			[Enum.KeyCode.Three] = 3
		}

		local skillIndex = keyMap[i.KeyCode]
		if skillIndex then
			local skillName = skillUsage(skillIndex)
			if skillName then
				print("Successfully used skill:", skillName)
			else
				print("Skill usage failed at index:", skillIndex)
			end
		end
	end
end)

–PathChoosing (Server)

local moduleScript = require(game.ReplicatedStorage.PathChoice.PathModule)
local players = game.Players

local function Path(plr, path)
	local pathData = nil

	for i, v in ipairs(moduleScript) do
		if v.Path == path then
			pathData = v
			break
		end
	end

	if pathData then
		print(plr.Name .. " selected path: " .. pathData.Path)
	end
end

local function SelectedPath(plr, selectedPath)
	local pathData = nil
	for i, v in ipairs(moduleScript) do
		if v.Path == selectedPath then
			pathData = v
			print("Selected Path: " .. v.Path)
			break
		end
	end
	if pathData then
		local pathSkills = pathData.PathSkills
		for _, skill in ipairs(pathSkills) do
			print(
				"Selected Path skill: " .. skill[1]
			)
		end
	end
end

players.PlayerAdded:Connect(function(plr)
	SelectedPath(plr, "Angel")
end)

–Module

return {
	{
		Path = "Ruin",
		PathSkills = {
			{
				"Darkness",
				Cooldown = 3,
				Duration = 2
			},
			{
				"My will",
				Cooldown = 3,
				Duration = 2
			}
		}
	},
	{
		Path = "Angel",
		PathSkills = {
			{
				"Divinity Healing",
				Cooldown = 4,
				Duration = 3
			},
			{
				"Enemy Duration", --[[ Selectable skill. ]]--
				Cooldown = 4,
				Duration = 3
			}
		}
	}
}

You need to be more clear on which part of the code does not work, you provided 3 parts, can you tell me where the print does not fire?

on the client, i want it to print the skill name,

 if skillIndex then
		local skillName = skillUsage(skillIndex)
		if skillName then
		print("Successfully used skill:", skillName)
	else
		print("Skill usage failed at index:", skillIndex)
	end
end

but i it wont do that

That’s cause you forgot to set the name of the skill, it’s just index, value instead of key, value

could u elaborate, in what way

{
	"Darkness", -- You forgot Name = "Darkness"
	Cooldown = 3,
	Duration = 2
},
1 Like

ohhhh, ill try it and see if it works

it works, thank you so much. Ill keep this in mind for future, once again, thank you!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.