Module firing error

firing (localscript):

local uis = game:GetService("UserInputService")
local rs = game:GetService("RunService")
local moves = require(game.ReplicatedStorage.Abilities)

if rs:IsRunning() then
	--started
end

uis.InputBegan:Connect(function(key,gpe)
	if gpe then return end
	if key.KeyCode.Name == "One" then

		moves["Fireball")](game.Players.LocalPlayer)		
	end
end)

module:

local module = {}



local abilities = {
	
	["Fireball"] = function(plr)
		print(plr)
	end,
	
	["Waterball"] = function()
		
	end,
	
}

return module

error:
23:33:16.796 Stack End - Studio
23:33:16.927 Players.Guest85851592.PlayerScripts.MoveOutputs:17: attempt to call a nil value - Client - MoveOutputs:17
23:33:16.927 Stack Begin - Studio
23:33:16.927 Script ‘Players.Guest85851592.PlayerScripts.MoveOutputs’, Line 17 - Studio - MoveOutputs:17
23:33:16.927 Stack End - Studio

inside the module, change local abilities to module.abilities

it didnt worked. still same issue :frowning:

Theres another issue in your local script which is the way you call the function. You have to access the table (abilities) and call the function through that. This script should fix that issue:

local uis = game:GetService("UserInputService")
local rs = game:GetService("RunService")
local moves = require(game.ReplicatedStorage.Abilities)

if rs:IsRunning() then
	--started
end

uis.InputBegan:Connect(function(key,gpe)
	if gpe then return end
	if key.KeyCode == Enum.KeyCode.Zero then
		
		moves.abilities.Fireball(game.Players.LocalPlayer)
	end
end)

ok but the thing is im plannign to do it like movecharacter.Move1.Value how can i fix it then?

Well this is all running on the client, you’re gonna need to port that code to the server if you want it to show up on other clients, but inside the Fireball function you can just do plr.Move1.Value = value

but inside module there will be more then over hundred moves fireball waterball others, so the move value will be fired to module

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