TestService: Exception thrown in your RayHit event handler: Argument 1 missing or nil

Not entirely sure whats wrong here but,

local M = require(game.ReplicatedStorage.Talents)

local function onRayHit(Cast, result, velocity, bullet)
	local hit = result.Instance
	local character = hit:FindFirstAncestorWhichIsA("Model")
	if character and character:FindFirstChild("Humanoid") then
		M.Damage()
	end
	delay(0, function()
		bulletCache:ReturnPart(bullet)
	end)
end

Using a module script for the damage as i want to add talents that can alter how the gun works

local Talents = {}

Talents.Damage = function()
	local T = game:GetService("ReplicatedStorage").Tals
	require(T:FindFirstChild(T1).Yes)
end

return Talents

Heres the module, using it to find a module with the same name as the first talent, currently have the talent as B

local module = {}

module.Yes = function()
	print("hi")
end

return module

and here’s the module “B”
But when i hit a someone i get the error


Any idea whats going wrong here?

2 Likes

(edit)
patched another part of the script but now get the error
TestService: Exception thrown in your RayHit event handler: Attempted to call require with invalid argument(s).

local Talents = {}

Talents.Damage = function()
	local T1 = script.Parent.T1
	local T = game:GetService("ReplicatedStorage").Tals
	local TG = require(T:FindFirstChild(T1))
	print(TG)
end


return Talents

image

and again T1 is still = B
(Edit in the edit)
For extra information, if it helps at all i did replace T1 with “B” and it did print so idk whats up

Found the solution, i was only defining the string value, not the actual value in the string value

local Talents = {}

Talents.Damage = function()
	local T1 = script.Parent.T1
	local T = game:GetService("ReplicatedStorage").Tals
	local TG = require(T:FindFirstChild(T1.Value))
	print(TG)
end


return Talents

This now works!