Issue with module script

so i was trying to make a system that allows me to easily give abilities to players, problem is

local module = {}
	
module.skillgiver = function(player,SkillName)
	local String = Instance.new("StringValue")
	String.Name = SkillName
		
	for i, v in game.ServerStorage.Skills:GetChildren() do
		if SkillName == v.Name then
			local skillgiver = v:Clone()
			local backpack = plr:WaitForChild("Backpack")
			skillgiver.Parent = backpack
		end
	end
end
	

return module

other script is

local part = script.Parent
local clickdetector = part:WaitForChild("ClickDetector")
local module = require(game:GetService("ReplicatedStorage").Modules.SkillGiver)

clickdetector.MouseClick:Connect(function()
	module.skillgiver(player,"SurfaceSlash")
end)
1 Like

Your “plr” is not even defined, or just change plr into player
If your plr type is string, you can FindFirstChild inside game.Players

Oh i didn’t see that

change “plr” on line 10 to “player”, as this is what you defined the player instance as on line 3 when the function is called.

however, this will still not solve your problem, you also need to define the player instance in your other script:

Change this on line 5:

clickdetector.MouseClick:Connect(function()

To this

clickdetector.MouseClick:Connect(function(player)

You need to check and know the error log meaning, not script isn’t working → post to the dev forum for help

Just a suggestion.

its a serverscript
should i use a local script?
alsoi got another error on the same line when I was trying to do WaitForChild(“Backpack”)

I just edited the message to a potential solution for you to use, let me know if it helps :slight_smile:

YES IT WORKS, thanks alot (word count)

1 Like

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