Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Modulescript not being called upon properly?

I've been working on a game based around having first person combat with like swords and such and decided it would just be easier to have a tool modulescript to work faster but I'm having difficulties

local _T = {}

local Players = game:GetService("Players")
Tool = script.Parent

function _T.ThirdPerson()
	Players.LocalPlayer.CameraMode = Enum.CameraMode.Classic
end

function _T.FirstPerson()
	Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
end

return _T

that is the module script and my code to call upon it is:



local Players = game:GetService("Players")
local ToolMod = require(game.Workspace.ToolMod)


Tool.Equipped:connect(FirstPerson)

Tool.Unequipped:connect(ThirdPerson)

2 comments

0

I've tried doing this before. It doesn't work for me either. Just turn it into an anonymous function that calls the module script function in the block.

0

Mainly my issue is you need to put the module nam before any line, aka T.Players = game_________ and _T.Tool =

1 answer

✓ Accepted answer

You'll have to do ToolMod.FirstPerson(), that's all there's to it.

2 comments

0

You want to pass the function not run it XD no need for the brackets.

0

Ahh dumb mistake but it's my first time using a module script, thank you!

This discussion is preserved as it was. New answers, comments, and votes are closed.