Files
Roblox-Elevator-Game/src/client/Player/UI/Crosshair.lua

47 lines
1.1 KiB
Lua

--!optimize 2
--!native
--!strict
local CrosshairModule = {
Icon = "rbxassetid://12643750723"
}
CrosshairModule.__index = CrosshairModule
local Storage = game:GetService("ReplicatedStorage")
local Easings = require(Storage:WaitForChild("AlgebraEasings"))
--Use a custom crosshair so we can do effects to it
type rbxassetid = string
function CrosshairModule.constructor(PlayerGui: PlayerGui)
local Screen = PlayerGui:WaitForChild("Crosshair")
local Icon = Screen:WaitForChild("ImageLabel")
return setmetatable({
Screen = Screen,
Icon = Icon
}, CrosshairModule)
end
function CrosshairModule:Enable()
(self.Screen :: ScreenGui).Enabled = true
end
function CrosshairModule:Disable()
(self.Screen :: ScreenGui).Enabled = false
end
function CrosshairModule:Change(ID: rbxassetid)
(self.Icon :: ImageLabel).Image = ID or CrosshairModule.Icon
end
function CrosshairModule:Jump(RootVelocity: Vector3)
local X, Y = RootVelocity.X, RootVelocity.Y;
(self.Icon :: ImageLabel).Position = UDim2.fromScale(
Y>1 and Easings.Linear(.5,.5+(X/1000),.3) or .5,
math.clamp(.4, .5-(-Y/1000), .6)
)
end
return CrosshairModule