On my UIS event, the function that I wrapped with it works but the event doesn’t
--Module Script
--Metatable
local fireball = {}
fireball.__index = fireball
--Services
local tweenService = game:GetService("TweenService")
local UIS = game:GetService("UserInputService")
--Constructor Function
function fireball.new(size, position, color)
local newFireball = {}
setmetatable(newFireball, fireball)
newFireball.Size = size
newFireball.Position = position
newFireball.Color = color
local fire = Instance.new("Part")
fire.Material = Enum.Material.Neon
fire.Parent = game.Workspace
fire.Position = position
fire.Size = size
fire.Color = color
newFireball.Fire = fire
return newFireball
end
function fireball:Animate()
local tweenInfo = TweenInfo.new(3, Enum.EasingStyle.Linear)
local tween = tweenService:Create(self.Fire, tweenInfo, {Position = self.Position * Vector3.new(0, 10, 0)})
tween:Play()
end
function fireball:KeyInput() -- How can I put a event here??
print("ok")
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.F then
print("Pressed F ")
end
end)
end
return fireball
--Server Script
--Services
local rs = game:GetService("ReplicatedStorage")
local fireball = require(rs:WaitForChild("ModuleScript"))
--Variables
local size = Vector3.new(3, 3, 3)
local position = Vector3.new(3, 3, 3)
local color = Color3.new(255, 0, 0)
--Constructor
local cool = fireball.new(size, position, color)
cool:Animate()
cool:KeyInput()
iceattack:Animationing() -- This one passes self automatically
or
iceattack.Animationing() -- If you use this one self doesn't get passed automatically