I’m tryin to get my code to run with my module but its giving me a error that is making no sense to me. What is happening?
Client:
-- Services --
local Players = game:GetService('Players')
local InputService = game:GetService('UserInputService')
local Replicated = game:GetService('ReplicatedStorage')
--
-- Variables --
local Player = Players.LocalPlayer
local Mouse = Player:GetMouse()
--
local Character = Player.Character
local Events = Replicated:FindFirstChild('Events')
--
-- Main --
InputService.InputBegan:Connect(function(Input,GPE)
if GPE then return end
--
local Binds = Input.UserInputType
local Bindz = Input.KeyCode
if Binds == Enum.UserInputType.MouseButton1 then
Events.NoTool.Catch.Event:FireServer('Catch')
elseif Bindz == Enum.KeyCode.E then
local Controls = require(Player.PlayerScripts:WaitForChild('Controls'))
Controls.Actions('Dive')
end
end)
--
Module:
local TA = {}
-- Services --
local Replicated = game:GetService('ReplicatedStorage')
local Players = game:GetService('Players')
--
local U2 = false
--
-- Dive Powers --
local Powers = {
Normal = {
Linear= 2.25,
Vertical = 2.5,
Rotation = 0.125
},
InAir = {
Linear= 1.7,
Vertical = 7,
Rotation = 0.092
}
}
--
local Anims = {
}
--
-- Functions --
function GetUp()
local Player = Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:WaitForChild('Humanoid')
--
U2 = false
Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
Humanoid.PlatformStand = false
task.wait(0.5)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping,true)
end
--
function Dive(P1,P2)
local Player = Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:WaitForChild('Humanoid')
local RootPart = Character:FindFirstChild('HumanoidRootPart')
--
U2 = true
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping,false)
local V6 = not Humanoid.Jumping and Powers.Normal or Powers.InAir
P2 = P2 or Humanoid.MoveDirection * Humanoid.WalkSpeed
--
RootPart.AssemblyLinearVelocity = Vector3.new(V6.Linear * P2.X,V6.Vertical,V6.Linear * P2.Z)
RootPart.AssemblyAngularVelocity = Vector3.new(P2.Z,0,-P2.X) * V6.Rotation
Humanoid.PlatformStand = true
end
--
function Actions(P5,P6)
if P6 == Enum.UserInputState.Begin then
if P5 == 'Dive' then
if not U2 then
Dive()
end
end
end
end
--
-- Main --
function TA.Start(P7)
end
--
Controls.Dive hasn’t been declared global in the modulescript.
Change this
to this
function TA.Dive(P1,P2)
local Player = Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:WaitForChild('Humanoid')
local RootPart = Character:FindFirstChild('HumanoidRootPart')
--
U2 = true
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping,false)
local V6 = not Humanoid.Jumping and Powers.Normal or Powers.InAir
P2 = P2 or Humanoid.MoveDirection * Humanoid.WalkSpeed
--
RootPart.AssemblyLinearVelocity = Vector3.new(V6.Linear * P2.X,V6.Vertical,V6.Linear * P2.Z)
RootPart.AssemblyAngularVelocity = Vector3.new(P2.Z,0,-P2.X) * V6.Rotation
Humanoid.PlatformStand = true
end