How do i get function with a string and also give arguments

I dont really know how to explain this but im trying to make a kill effect for weapons and i need to require a module using a string but also give some arguments but this is not working

Server Script

if ClientModule.KillEffect ~= nil then
	require(Modules.KillEffects)[ClientModule.KillEffect](Ragdoll)
end

KillEffects module

local module = {}

function module.Golfify(Ragdoll)
	for _,v in pairs(Ragdoll:GetDescendants()) do
		if v:IsA("BasePart") then
			local Weld = Instance.new("Weld", v)
			Weld.Part0 = Ragdoll.HumanoidRootPart
			Weld.Part1 = v
			
			v.Material = Enum.Material.Metal
			v.Color = Color3.new(1, 1, 0)
		end
	end
end

return module

ClientModule

KillEffect = "Goldify"

sorry for bad english or dumb explanation

Hey there! I tested your script and it works perfectly fine. Are you sure ClientModule.KillEffect isn’t nil, or there isn’t any errors in your module?

well for me its not working just fine. I checked if there is a issue with module but no its issue inside the server script


it should print “OKE” atleast

Simple typo mistake, don’t worry, it happens to all of us :slight_smile:

image
image

1 Like

oh alright thank you so much man!

1 Like

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