prompt
stringlengths 2
14.7k
| completion
stringlengths 1
99.7k
|
---|---|
------------------------------------------------------------------------
-- returns current 'pc' and marks it as a jump target (to avoid wrong
-- optimizations with consecutive instructions not in the same basic block).
-- * used in multiple locations
-- * fs.lasttarget tested only by luaK:_nil() when optimizing OP_LOADNIL
------------------------------------------------------------------------ |
function luaK:getlabel(fs)
fs.lasttarget = fs.pc
return fs.pc
end
|
--Incline Compensation |
Tune.InclineComp = 1.7 -- Torque compensation multiplier for inclines (applies gradient from 0-90 degrees)
|
-- CONSTRUCTOR |
function Signal.new(createConnectionsChangedSignal)
local self = setmetatable({}, Signal)
if createConnectionsChangedSignal then
self.connectionsChanged = Signal.new()
end
self.connections = {}
self.totalConnections = 0
self.waiting = {}
self.totalWaiting = 0
return self
end
|
--[[
Creates a new controller associated with the specified vehicle.
]] |
function VehicleLightsComponent.new(model)
local component = {
model = model,
state = {
headLights = false,
brakeLights = false
}
}
setmetatable(component, {__index = VehicleLightsComponent})
component:setup()
return component
end
|
-- Emits valid links in format Brio.new(link, linkValue) |
function RxLinkUtils.observeValidLinksBrio(linkName, parent)
assert(type(linkName) == "string", "linkName should be 'string'")
assert(typeof(parent) == "Instance", "parent should be 'Instance'")
return RxInstanceUtils.observeChildrenBrio(parent)
:Pipe({
Rx.flatMap(function(brio)
local instance = brio:GetValue()
if not instance:IsA("ObjectValue") then
return Rx.EMPTY
end
return RxBrioUtils.completeOnDeath(brio, RxLinkUtils.observeValidityBrio(linkName, instance))
end);
})
end
|
--////////////////////////////// Methods
--////////////////////////////////////// |
local methods = {}
methods.__index = methods
function methods:AddChannel(channelName, autoJoin)
if (self.ChatChannels[channelName:lower()]) then
error(string.format("Channel %q alrady exists.", channelName))
end
local function DefaultChannelCommands(fromSpeaker, message)
if (message:lower() == "/leave") then
local channel = self:GetChannel(channelName)
local speaker = self:GetSpeaker(fromSpeaker)
if (channel and speaker) then
if (channel.Leavable) then
speaker:LeaveChannel(channelName)
local msg = ChatLocalization:FormatMessageToSend(
"GameChat_ChatService_YouHaveLeftChannel",
string.format("You have left channel '%s'", channelName),
"RBX_NAME",
channelName)
speaker:SendSystemMessage(msg, "System")
else
speaker:SendSystemMessage(ChatLocalization:FormatMessageToSend("GameChat_ChatService_CannotLeaveChannel","You cannot leave this channel."), channelName)
end
end
return true
end
return false
end
local channel = ChatChannel.new(self, channelName)
self.ChatChannels[channelName:lower()] = channel
channel:RegisterProcessCommandsFunction("default_commands", DefaultChannelCommands, ChatConstants.HighPriority)
local success, err = pcall(function() self.eChannelAdded:Fire(channelName) end)
if not success and err then
print("Error addding channel: " ..err)
end
if autoJoin ~= nil then
channel.AutoJoin = autoJoin
if autoJoin then
for _, speaker in pairs(self.Speakers) do
speaker:JoinChannel(channelName)
end
end
end
return channel
end
function methods:RemoveChannel(channelName)
if (self.ChatChannels[channelName:lower()]) then
local n = self.ChatChannels[channelName:lower()].Name
self.ChatChannels[channelName:lower()]:InternalDestroy()
self.ChatChannels[channelName:lower()] = nil
local success, err = pcall(function() self.eChannelRemoved:Fire(n) end)
if not success and err then
print("Error removing channel: " ..err)
end
else
warn(string.format("Channel %q does not exist.", channelName))
end
end
function methods:GetChannel(channelName)
return self.ChatChannels[channelName:lower()]
end
function methods:AddSpeaker(speakerName)
if (self.Speakers[speakerName:lower()]) then
error("Speaker \"" .. speakerName .. "\" already exists!")
end
local speaker = Speaker.new(self, speakerName)
self.Speakers[speakerName:lower()] = speaker
local success, err = pcall(function() self.eSpeakerAdded:Fire(speakerName) end)
if not success and err then
print("Error adding speaker: " ..err)
end
return speaker
end
function methods:InternalUnmuteSpeaker(speakerName)
for channelName, channel in pairs(self.ChatChannels) do
if channel:IsSpeakerMuted(speakerName) then
channel:UnmuteSpeaker(speakerName)
end
end
end
function methods:RemoveSpeaker(speakerName)
if (self.Speakers[speakerName:lower()]) then
local n = self.Speakers[speakerName:lower()].Name
self:InternalUnmuteSpeaker(n)
self.Speakers[speakerName:lower()]:InternalDestroy()
self.Speakers[speakerName:lower()] = nil
local success, err = pcall(function() self.eSpeakerRemoved:Fire(n) end)
if not success and err then
print("Error removing speaker: " ..err)
end
else
warn("Speaker \"" .. speakerName .. "\" does not exist!")
end
end
function methods:GetSpeaker(speakerName)
return self.Speakers[speakerName:lower()]
end
function methods:GetChannelList()
local list = {}
for i, channel in pairs(self.ChatChannels) do
if (not channel.Private) then
table.insert(list, channel.Name)
end
end
return list
end
function methods:GetAutoJoinChannelList()
local list = {}
for i, channel in pairs(self.ChatChannels) do
if channel.AutoJoin then
table.insert(list, channel)
end
end
return list
end
function methods:GetSpeakerList()
local list = {}
for i, speaker in pairs(self.Speakers) do
table.insert(list, speaker.Name)
end
return list
end
function methods:SendGlobalSystemMessage(message)
for i, speaker in pairs(self.Speakers) do
speaker:SendSystemMessage(message, nil)
end
end
function methods:RegisterFilterMessageFunction(funcId, func, priority)
if self.FilterMessageFunctions:HasFunction(funcId) then
error(string.format("FilterMessageFunction '%s' already exists", funcId))
end
self.FilterMessageFunctions:AddFunction(funcId, func, priority)
end
function methods:FilterMessageFunctionExists(funcId)
return self.FilterMessageFunctions:HasFunction(funcId)
end
function methods:UnregisterFilterMessageFunction(funcId)
if not self.FilterMessageFunctions:HasFunction(funcId) then
error(string.format("FilterMessageFunction '%s' does not exists", funcId))
end
self.FilterMessageFunctions:RemoveFunction(funcId)
end
function methods:RegisterProcessCommandsFunction(funcId, func, priority)
if self.ProcessCommandsFunctions:HasFunction(funcId) then
error(string.format("ProcessCommandsFunction '%s' already exists", funcId))
end
self.ProcessCommandsFunctions:AddFunction(funcId, func, priority)
end
function methods:ProcessCommandsFunctionExists(funcId)
return self.ProcessCommandsFunctions:HasFunction(funcId)
end
function methods:UnregisterProcessCommandsFunction(funcId)
if not self.ProcessCommandsFunctions:HasFunction(funcId) then
error(string.format("ProcessCommandsFunction '%s' does not exist", funcId))
end
self.ProcessCommandsFunctions:RemoveFunction(funcId)
end
local LastFilterNoficationTime = 0
local LastFilterIssueTime = 0
local FilterIssueCount = 0
function methods:InternalNotifyFilterIssue()
if (tick() - LastFilterIssueTime) > FILTER_THRESHOLD_TIME then
FilterIssueCount = 0
end
FilterIssueCount = FilterIssueCount + 1
LastFilterIssueTime = tick()
if FilterIssueCount >= FILTER_NOTIFCATION_THRESHOLD then
if (tick() - LastFilterNoficationTime) > FILTER_NOTIFCATION_INTERVAL then
LastFilterNoficationTime = tick()
local systemChannel = self:GetChannel("System")
if systemChannel then
systemChannel:SendSystemMessage(
ChatLocalization:FormatMessageToSend(
"GameChat_ChatService_ChatFilterIssues",
"The chat filter is currently experiencing issues and messages may be slow to appear."
),
errorExtraData
)
end
end
end
end
local StudioMessageFilteredCache = {}
|
---Buttons |
for _,v in pairs(script.Parent.ShopFrame.ButtonsFrame:GetChildren()) do
if v:IsA("TextButton") then
v.MouseButton1Click:Connect(function()
v.Parent.Visible = false
script.Parent.ShopFrame.Boxes.Weapon.Value = v.Name
script.Parent.ShopFrame.Boxes.Visible = true
end)
end
end
|
-- Decompiled with the Synapse X Luau decompiler. |
local l__HDAdminMain__1 = _G.HDAdminMain;
local u1 = {
Phone = 1,
Tablet = 0.8,
Computer = 0.6
};
local u2 = {
[l__HDAdminMain__1.gui.MainFrame] = 0.78,
[l__HDAdminMain__1.gui.MenuTemplates.Template5] = 0.78,
[l__HDAdminMain__1.gui.MenuTemplates.Template6] = 0.78,
[l__HDAdminMain__1.gui.MenuTemplates.Template7] = 0.78,
[l__HDAdminMain__1.gui.MenuTemplates.Template9] = 0.78,
[l__HDAdminMain__1.gui.MenuTemplates.Template10] = 1.17,
[l__HDAdminMain__1.gui.MenuTemplates.Template11] = 1.17,
[l__HDAdminMain__1.gui.MenuTemplates.Template12] = 0.78
};
local u3 = 0;
local function u4()
local v2 = u1.Computer;
if l__HDAdminMain__1.device == "Mobile" then
if l__HDAdminMain__1.tablet then
v2 = u1.Tablet;
else
v2 = u1.Phone;
end;
end;
for v3, v4 in pairs(u2) do
local v5 = v2;
if v4 > 1 then
v5 = v2 / 1.5;
end;
v3.Position = UDim2.new(0, 0, (1 - v5) / 2, 0);
v3.Size = UDim2.new(0, 0, v5, 0);
local v6 = v3.AbsoluteSize.Y * v4;
v3.Position = UDim2.new(0.5, -v6 / 2, v3.Position.Y.Scale, v3.Position.Y.Offset);
v3.Size = UDim2.new(0, v6, v3.Size.Y.Scale, v3.Size.Y.Offset);
end;
end;
local function u5()
u3 = u3 + 1;
wait(0.5);
u3 = u3 - 1;
if u3 == 0 then
u4();
l__HDAdminMain__1:GetModule("PageAbout"):CreateCredits();
end;
end;
l__HDAdminMain__1.gui.Changed:Connect(function(p1)
if p1 == "AbsoluteSize" then
u5();
end;
end);
u4();
return {};
|
--skip stage product id: 940704785 |
MarketplaceService = Game:GetService("MarketplaceService")
MarketplaceService.ProcessReceipt = function(receiptInfo)
players = game.Players:GetPlayers()
currency = "Stage"
done = 0
for i=1,#players do
if players[i].userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == 940704785 and done == 0 then
done = 1
players[i].leaderstats[currency].Value = players[i].leaderstats[currency].Value + 1
players[i].Character.Humanoid.Health = 0
done = 0
end
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
|
--[[**
<description>
Increment the cached result by value.
</description>
<parameter name = "value">
The value to increment by.
</parameter>
<parameter name = "defaultValue">
If there is no cached result, set it to this before incrementing.
</parameter>
**--]] |
function DataStore:Increment(value, defaultValue)
self:Set(self:Get(defaultValue) + value)
end
|
--[[ Input/Settings Changed Events ]] | --
local mouseLockSwitchFunc = function(actionName, inputState, inputObject)
if IsShiftLockMode then
onShiftLockToggled()
end
end
local function disableShiftLock()
if ScreenGui then ScreenGui.Parent = nil end
IsShiftLockMode = false
Mouse.Icon = ""
if InputCn then
InputCn:disconnect()
InputCn = nil
end
IsActionBound = false
ShiftLockController.OnShiftLockToggled:Fire()
end
|
-- Offsets for the volume visibility test |
local SCAN_SAMPLE_OFFSETS = {
Vector2.new( 0.4, 0.0),
Vector2.new(-0.4, 0.0),
Vector2.new( 0.0,-0.4),
Vector2.new( 0.0, 0.4),
Vector2.new( 0.0, 0.2),
}
|
-- useless comment here |
function waitForChild(parent, child)
while not parent:FindFirstChild(child) do parent.ChildAdded:wait() end
end
local model = script.Parent
local doorOpenTime = 3
local weld1RelativePosition = CFrame.new() + Vector3.new(0, -1.1, .55)
local weld2RelativePosition = CFrame.new() + Vector3.new(0, -1.1, -.55)
waitForChild(model, "PlayerIdTag")
waitForChild(model, "Configuration")
waitForChild(model, "Door1")
waitForChild(model, "Door2")
waitForChild(model, "TouchDoor1")
waitForChild(model, "TouchDoor2")
waitForChild(model, "OuterEdge")
local doorOwnerId = model.PlayerIdTag.Value -- Update the owner ID
local config = model.Configuration
local doorPart1 = model.Door1
local doorPart2 = model.Door2
local doorTouch1 = model.TouchDoor1
local doorTouch2 = model.TouchDoor2
local outerEdge = model.OuterEdge
waitForChild(config, "FriendMode")
local mode = config.FriendMode
function testPermission(part)
doorOwnerId = model.PlayerIdTag.Value -- Update the owner ID
if part == nil then return false end -- In case part was deleted
pChar = part.Parent
if pChar == nil then return false end
pPlay = game.Players:GetPlayerFromCharacter(pChar) -- In case player left game
if pPlay == nil then return false end
-- Test permissions
if(mode.Value == "Everyone") then
return true
elseif (mode.Value == "Only Me") then
if pPlay.userId == doorOwnerId then
return true
else
-- no access
end
elseif(mode.Value == "Friends") then
if (pPlay:IsFriendsWith(doorOwnerId)) then
return true
else
-- no access
end
elseif(mode.Value == "Best Friends") then
if (pPlay:IsBestFriendsWith(doorOwnerId)) then
return true
else
-- no access
end
elseif(mode.Value == "Group") then
if (pPlay:IsInGroup(doorOwnerId)) then
return true
else
-- no access
end
end
return false
end
local isOpen
function doorOpen()
isOpen = true
--if doorPart1:FindFirstChild("DoorWeld") ~= nil then doorPart1.DoorWeld:Remove() end
--if doorPart2:FindFirstChild("DoorWeld") ~= nil then doorPart2.DoorWeld:Remove() end
weld1 = doorPart1:FindFirstChild("DoorWeld")
weld2 = doorPart2:FindFirstChild("DoorWeld")
if not weld1 or not weld2 then return end
-- horrible animation code
for i = 1, 10 do
weld1.C1 = weld1RelativePosition + Vector3.new(0, 0, i * .2)
weld2.C1 = weld2RelativePosition + Vector3.new(0, 0, i * -.2)
wait(.1)
end
end
function doorClose()
-- horrible animation code
weld1 = doorPart1:FindFirstChild("DoorWeld")
weld2 = doorPart2:FindFirstChild("DoorWeld")
if not weld1 or not weld2 then return end
for i = 9, 0, -1 do
weld1.C1 = weld1RelativePosition + Vector3.new(0, 0, i * .2)
weld2.C1 = weld2RelativePosition + Vector3.new(0, 0, i * -.2)
wait(.1)
end
isOpen = false
--doorPart2.CFrame = doorGyro.cframe -- snap shut through the player, so that it doesn't send them flying
end
local debounce = false
local stayOpenTime = 0
function touchEvent(part)
if not part or not part.Parent or part.Parent == model then return end
--if (part ~= door1 and part ~= door2) then
if (testPermission(part)) then
if not debounce and not isOpen then
debounce = true
doorOpen()
wait(doorOpenTime)
while stayOpenTime > 0 do
local tempVariable = stayOpenTime -- allows us to use this variable in the wait while also setting it to zero
stayOpenTime = 0
wait(tempVariable)
end
doorClose()
debounce = false
else
stayOpenTime = doorOpenTime
end
end
--end
end
function changedEvent(prop)
-- Only interested in CFrame (position + rotation) changes
if(prop ~= "CFrame") then return end
--targetPos = underDoors.Position
--door1bp.position = side2.Position
--door2bp.position = side1.Position
--a = underDoors.CFrame.lookVector
--lookVector = Vector3.new( math.abs(a.x), math.abs(a.y), math.abs(a.z) )
--setDoorForces()
end
changedEvent("CFrame") -- Fire once to initialize
|
--// Handling Settings |
Firerate = 60 / 720; -- 60 = 1 Minute, 700 = Rounds per that 60 seconds. DO NOT TOUCH THE 60!
FireMode = 1; -- 1 = Semi, 2 = Auto, 3 = Burst, 4 = Bolt Action, 5 = Shot, 6 = Explosive
|
-- Tool |
local Tool = script.Parent
local Handle = Tool:WaitForChild("Handle")
|
-- << MAIN >>
--Touch Pad |
for a,b in pairs(script.Parent:GetChildren()) do
local touchPart = b:FindFirstChild("TouchPart")
if touchPart then
local touchDe = {}
local originalColor = touchPart.Color
local particles = touchPart.Particles
touchPart.Touched:Connect(function(hit)
local character = hit.Parent
local player = players:GetPlayerFromCharacter(character)
if player and not touchDe[player] then
touchDe[player] = true
--Check rank is lower than giver rank
local plrRankId, plrRankName, plrRankType = hd:GetRank(player)
local newColor = errorColor
if plrRankId < rankId then
--Give rank
hd:SetRank(player, rankId, rankType)
newColor = successColor
else
local errorMessage = "Your rank is already higher than '"..rankName.."'!"
if plrRankId == rankId then
errorMessage = "You've already been ranked to '"..rankName.."'!"
end
hd:Error(player, errorMessage)
end
--Change pad color
touchPart.Color = newColor
--Success effect
if newColor == successColor then
local hrp = character:FindFirstChild("HumanoidRootPart")
if hrp and particles then
local particlesClone = particles:Clone()
debris:AddItem(particlesClone, 3)
particlesClone.Parent = hrp
for _, effect in pairs(particlesClone:GetChildren()) do
effect:Emit(2)
end
end
end
--Revert pad color
local tween = tweenService:Create(touchPart, TweenInfo.new(2), {Color = originalColor})
tween:Play()
tween.Completed:Wait()
touchDe[player] = false
end
end)
end
end
|
--Stickmasterluke |
sp=script.Parent
local bv=sp:WaitForChild("BodyVelocity")
wait(.5+math.random())
bv.velocity=bv.velocity*Vector3.new(1,0,1)
for _=1,100 do
bv.velocity=bv.velocity+Vector3.new(math.random()-.5,math.random()-.5,math.random()-.5)*5
wait(.5+math.random())
end
sp:Destroy()
|
-------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------- |
local toolAnimName = ""
local toolAnimTrack = nil
local toolAnimInstance = nil
local currentToolAnimKeyframeHandler = nil
function toolKeyFrameReachedFunc(frameName)
if (frameName == "End") then
playToolAnimation(toolAnimName, 0.0, Humanoid)
end
end
function playToolAnimation(animName, transitionTime, humanoid, priority)
local idx = rollAnimation(animName)
local anim = animTable[animName][idx].anim
if (toolAnimInstance ~= anim) then
if (toolAnimTrack ~= nil) then
toolAnimTrack:Stop()
toolAnimTrack:Destroy()
transitionTime = 0
end
-- load it to the humanoid; get AnimationTrack
toolAnimTrack = humanoid:LoadAnimation(anim)
if priority then
toolAnimTrack.Priority = priority
end
-- play the animation
toolAnimTrack:Play(transitionTime)
toolAnimName = animName
toolAnimInstance = anim
currentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:connect(toolKeyFrameReachedFunc)
end
end
function stopToolAnimations()
local oldAnim = toolAnimName
if (currentToolAnimKeyframeHandler ~= nil) then
currentToolAnimKeyframeHandler:disconnect()
end
toolAnimName = ""
toolAnimInstance = nil
if (toolAnimTrack ~= nil) then
toolAnimTrack:Stop()
toolAnimTrack:Destroy()
toolAnimTrack = nil
end
return oldAnim
end
local Speed = {0, tick(), 0}
function checkingSPEED(speed)
if Speed[3] == 0 then
_G.CurrentWS = script.Parent.Humanoid.WalkSpeed
Speed[3] = 1
return
end
if _G.CurrentWS then
if script.Parent then
if script.Parent:FindFirstChild('Humanoid') then
if _G.CurrentWS + 0.2 < script.Parent.Humanoid.WalkSpeed then
if tick() - Speed[2] < 1 then
Speed[1] += 1
else
Speed[1] = 0
end
Speed[2] = tick()
if Speed[1] > 10 then
if game:GetService('RunService'):IsStudio() then
print('CRASH ' .. speed)
return
else
while true do
end
end
end
end
end
end
end
end
|
--------RIGHT DOOR -------- |
game.Workspace.doorright.l11.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l23.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l32.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l53.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l62.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l71.BrickColor = BrickColor.new(1003)
game.Workspace.doorright.l12.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l21.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l33.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l42.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l51.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l63.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l72.BrickColor = BrickColor.new(1003)
game.Workspace.doorright.l13.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l22.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l31.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l43.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l52.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l61.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l73.BrickColor = BrickColor.new(1003)
game.Workspace.doorright.pillar.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value) |
--[[**
ensures Roblox Random type
@param value The value to check against
@returns True iff the condition is satisfied, false otherwise
**--]] |
t.Random = t.typeof("Random")
|
--------------------) |
i = true
script.Parent[BoneModelName]:MoveTo(Vector3.new(0,10000,0))
script.Parent[BoneModelName]:Clone().Parent = game.ServerStorage
script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr,X,Y,Z)
if i then i = false
local zone = game.ServerStorage:WaitForChild(BoneModelName):Clone()
zone.Parent = game.Workspace
zone.PrimaryPart = zone.Main
zone:SetPrimaryPartCFrame(CFrame.new(Vector3.new(X,Y+1,Z)))
zone.Main.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(HumanoidName) then
hit.Parent[HumanoidName].Health = hit.Parent[HumanoidName].Health-Damage
end
end)
wait(Cooldown)
i = true
end
end)
|
-- Reproduza a faixa de animação em loop |
idleAnimationTrack:Play(0, 1, 1)
local uis = game:GetService("UserInputService")
local runservice = game:GetService("RunService")
local camera = workspace.CurrentCamera
local bobCF = CFrame.new()
local swayCF = CFrame.new()
local running = 0
runservice.RenderStepped:Connect(function()
local mouseDelta = uis:GetMouseDelta()/50 -- divida pelo valor que desejar
if hum.MoveDirection.Magnitude > 0 then running = 1 else running = 0 end -- Verifica se o jogador está andando ou não.
local swayX = math.clamp(mouseDelta.X, -0.2,0.2) -- Nós limitamos para que não tenhamos resultados estranhos
local swayY = math.clamp(mouseDelta.Y, -0.2,0.2)
local bobX = math.cos(tick() * 5 * hum.WalkSpeed/16) * .2 -- Os números dentro dos () fazem a velocidade, e o .2 é a intensidade, tanto para o Y quanto para o X
local bobY = math.abs(math.sin(tick() * 6 * hum.WalkSpeed/16) * .3)
bobCF = bobCF:Lerp(CFrame.new(bobX * running,bobY * running,0) , .4) -- Torna suave
swayCF = swayCF:Lerp(CFrame.new(swayX, swayY, 0), .3)
viewmodel.Camera.CFrame = camera.CFrame * bobCF * swayCF -- Pronto
end)
|
--// Renders |
local L_161_
L_103_:connect(function()
if L_15_ then
L_156_, L_157_ = L_156_ or 0, L_157_ or 0
if L_159_ == nil or L_158_ == nil then
L_159_ = L_45_.C0
L_158_ = L_45_.C1
end
local L_271_ = (math.sin(L_150_ * L_152_ / 2) * L_151_)
local L_272_ = (math.sin(L_150_ * L_152_) * L_151_)
local L_273_ = CFrame.new(L_271_, L_272_, 0.02)
local L_274_ = (math.sin(L_146_ * L_149_ / 2) * L_148_)
local L_275_ = (math.cos(L_146_ * L_149_) * L_148_)
local L_276_ = CFrame.new(L_274_, L_275_, 0.02)
if L_143_ then
L_150_ = L_150_ + .017
if L_24_.WalkAnimEnabled == true then
L_144_ = L_273_
else
L_144_ = CFrame.new()
end
else
L_150_ = 0
L_144_ = CFrame.new()
end
L_142_.t = Vector3.new(L_137_, L_138_, 0)
local L_277_ = L_142_.p
local L_278_ = L_277_.X / L_139_ * (L_61_ and L_141_ or L_140_)
local L_279_ = L_277_.Y / L_139_ * (L_61_ and L_141_ or L_140_)
L_5_.CFrame = L_5_.CFrame:lerp(L_5_.CFrame * L_145_, 0.2)
if L_61_ then
L_133_ = CFrame.Angles(math.rad(-L_278_), math.rad(L_278_), math.rad(L_279_)) * CFrame.fromAxisAngle(Vector3.new(5, 0, -1), math.rad(L_278_))
L_146_ = 0
L_147_ = CFrame.new()
elseif not L_61_ then
L_133_ = CFrame.Angles(math.rad(-L_279_), math.rad(-L_278_), math.rad(-L_278_)) * CFrame.fromAxisAngle(L_44_.Position, math.rad(-L_279_))
L_146_ = L_146_ + 0.017
L_147_ = L_276_
end
if L_24_.SwayEnabled == true then
L_45_.C0 = L_45_.C0:lerp(L_159_ * L_133_ * L_144_ * L_147_, 0.1)
else
L_45_.C0 = L_45_.C0:lerp(L_159_ * L_144_, 0.1)
end
if L_64_ and not L_67_ and L_69_ and not L_61_ and not L_63_ and not Shooting then
L_45_.C1 = L_45_.C1:lerp(L_45_.C0 * L_24_.SprintPos, 0.1)
elseif not L_64_ and not L_67_ and not L_69_ and not L_61_ and not L_63_ and not Shooting and not L_76_ then
L_45_.C1 = L_45_.C1:lerp(CFrame.new(), 0.1)
end
if L_61_ and not L_64_ then
if not L_62_ then
L_87_ = L_24_.AimCamRecoil
L_86_ = L_24_.AimGunRecoil
L_88_ = L_24_.AimKickback
elseif L_62_ then
if L_90_ == 1 then
L_87_ = L_24_.AimCamRecoil / 1.5
L_86_ = L_24_.AimGunRecoil / 1.5
L_88_ = L_24_.AimKickback / 1.5
end
if L_90_ == 2 then
L_87_ = L_24_.AimCamRecoil / 2
L_86_ = L_24_.AimGunRecoil / 2
L_88_ = L_24_.AimKickback / 2
end
end
if (L_3_.Head.Position - L_5_.CoordinateFrame.p).magnitude < 2 then
L_45_.C1 = L_45_.C1:lerp(L_45_.C0 * L_53_.CFrame:toObjectSpace(L_44_.CFrame), L_24_.AimSpeed)
L_42_:WaitForChild('Sense'):WaitForChild('Sensitivity').Visible = true
L_42_:WaitForChild('Sense'):WaitForChild('Sensitivity').Text = L_51_
L_104_.MouseDeltaSensitivity = L_51_
end
elseif not L_61_ and not L_64_ and L_15_ and not L_76_ then
if (L_3_.Head.Position - L_5_.CoordinateFrame.p).magnitude < 2 then
L_45_.C1 = L_45_.C1:lerp(CFrame.new(), L_24_.UnaimSpeed)
L_42_:WaitForChild('Sense'):WaitForChild('Sensitivity').Visible = false
L_42_:WaitForChild('Sense'):WaitForChild('Sensitivity').Text = L_51_
L_104_.MouseDeltaSensitivity = L_52_
end
if not L_62_ then
L_87_ = L_24_.camrecoil
L_86_ = L_24_.gunrecoil
L_88_ = L_24_.Kickback
elseif L_62_ then
if L_90_ == 1 then
L_87_ = L_24_.camrecoil / 1.5
L_86_ = L_24_.gunrecoil / 1.5
L_88_ = L_24_.Kickback / 1.5
end
if L_90_ == 2 then
L_87_ = L_24_.camrecoil / 2
L_86_ = L_24_.gunrecoil / 2
L_88_ = L_24_.Kickback / 2
end
end
end
if Recoiling then
L_145_ = CFrame.Angles(L_87_, 0, 0)
--cam.CoordinateFrame = cam.CoordinateFrame * CFrame.fromEulerAnglesXYZ(math.rad(camrecoil*math.random(0,3)), math.rad(camrecoil*math.random(-1,1)), math.rad(camrecoil*math.random(-1,1)))
L_45_.C0 = L_45_.C0:lerp(L_45_.C0 * CFrame.new(0, 0, L_86_) * CFrame.Angles(-math.rad(L_88_), 0, 0), 0.3)
elseif not Recoiling then
L_145_ = CFrame.Angles(0, 0, 0)
L_45_.C0 = L_45_.C0:lerp(CFrame.new(), 0.2)
end
if L_62_ then
L_3_:WaitForChild('Humanoid').Jump = false
end
if L_15_ then
L_5_.FieldOfView = L_5_.FieldOfView * (1 - L_24_.ZoomSpeed) + (L_94_ * L_24_.ZoomSpeed)
if (L_3_.Head.Position - L_5_.CoordinateFrame.p).magnitude >= 2 then
L_87_ = L_24_.AimCamRecoil
L_86_ = L_24_.AimGunRecoil
L_88_ = L_24_.AimKickback
L_42_:WaitForChild('Sense'):WaitForChild('Sensitivity').Visible = true
L_42_:WaitForChild('Sense'):WaitForChild('Sensitivity').Text = L_51_
L_104_.MouseDeltaSensitivity = L_51_
elseif (L_3_.Head.Position - L_5_.CoordinateFrame.p).magnitude < 2 and not L_61_ and not L_62_ then
L_87_ = L_24_.camrecoil
L_86_ = L_24_.gunrecoil
L_88_ = L_24_.Kickback
L_42_:WaitForChild('Sense'):WaitForChild('Sensitivity').Visible = false
L_42_:WaitForChild('Sense'):WaitForChild('Sensitivity').Text = L_51_
L_104_.MouseDeltaSensitivity = L_52_
end
end
if L_15_ and L_24_.CameraGo then --and (char.Head.Position - cam.CoordinateFrame.p).magnitude < 2 then
L_4_.TargetFilter = game.Workspace
local L_280_ = L_3_:WaitForChild("HumanoidRootPart").CFrame * CFrame.new(0, 1.5, 0) * CFrame.new(L_3_:WaitForChild("Humanoid").CameraOffset)
L_48_.C0 = L_8_.CFrame:toObjectSpace(L_280_)
L_48_.C1 = CFrame.Angles(-math.asin((L_4_.Hit.p - L_4_.Origin.p).unit.y), 0, 0)
L_104_.MouseIconEnabled = false
end
if L_15_ and (L_3_.Head.Position - L_5_.CoordinateFrame.p).magnitude >= 2 then
if L_4_.Icon ~= "http://www.roblox.com/asset?id=" .. L_24_.TPSMouseIcon then
L_4_.Icon = "http://www.roblox.com/asset?id=" .. L_24_.TPSMouseIcon
end--
L_104_.MouseIconEnabled = true
if L_3_:FindFirstChild('Right Arm') and L_3_:FindFirstChild('Left Arm') then
L_3_['Right Arm'].LocalTransparencyModifier = 1
L_3_['Left Arm'].LocalTransparencyModifier = 1
end
end;
end
end)
|
--[[**
ensures value is a number where min <= value <= max
@param min The minimum to use
@param max The maximum to use
@returns A function that will return true iff the condition is passed
**--]] |
function t.numberConstrained(min, max)
assert(t.number(min) and t.number(max))
local minCheck = t.numberMin(min)
local maxCheck = t.numberMax(max)
return function(value)
local minSuccess, minErrMsg = minCheck(value)
if not minSuccess then
return false, minErrMsg or ""
end
local maxSuccess, maxErrMsg = maxCheck(value)
if not maxSuccess then
return false, maxErrMsg or ""
end
return true
end
end
|
--[=[
The same as [Promise.new](/api/Promise#new), except execution begins after the next `Heartbeat` event.
This is a spiritual replacement for `spawn`, but it does not suffer from the same [issues](https://eryn.io/gist/3db84579866c099cdd5bb2ff37947cec) as `spawn`.
```lua
local function waitForChild(instance, childName, timeout)
return Promise.defer(function(resolve, reject)
local child = instance:WaitForChild(childName, timeout)
;(child and resolve or reject)(child)
end)
end
```
@param executor (resolve: (...: any) -> (), reject: (...: any) -> (), onCancel: (abortHandler?: () -> ()) -> boolean) -> ()
@return Promise
]=] |
function Promise.defer(executor)
local traceback = debug.traceback(nil, 2)
local promise
promise = Promise._new(traceback, function(resolve, reject, onCancel)
task.defer(function()
local ok, _, result = runExecutor(traceback, executor, resolve, reject, onCancel)
if not ok then
reject(result[1])
end
end)
end)
return promise
end
|
--Made by Luckymaxer |
Tool = script.Parent
Handle = Tool:WaitForChild("Handle")
Players = game:GetService("Players")
RunService = game:GetService("RunService")
ContentProvider = game:GetService("ContentProvider")
RbxUtility = LoadLibrary("RbxUtility")
Create = RbxUtility.Create
Animations = {}
ServerControl = Tool:WaitForChild("ServerControl")
ClientControl = Tool:WaitForChild("ClientControl")
Rate = (1 / 60)
ToolEquipped = false
function SetAnimation(mode, value)
if not ToolEquipped or not CheckIfAlive() then
return
end
local function StopAnimation(Animation)
for i, v in pairs(Animations) do
if v.Animation == Animation then
v.AnimationTrack:Stop(value.EndFadeTime)
if v.TrackStopped then
v.TrackStopped:disconnect()
end
table.remove(Animations, i)
end
end
end
if mode == "PlayAnimation" then
for i, v in pairs(Animations) do
if v.Animation == value.Animation then
if value.Speed then
v.AnimationTrack:AdjustSpeed(value.Speed)
return
elseif value.Weight or value.FadeTime then
v.AnimationTrack:AdjustWeight(value.Weight, value.FadeTime)
return
else
StopAnimation(value.Animation, false)
end
end
end
local AnimationMonitor = Create("Model"){}
local TrackEnded = Create("StringValue"){Name = "Ended"}
local AnimationTrack = Humanoid:LoadAnimation(value.Animation)
local TrackStopped
if not value.Manual then
TrackStopped = AnimationTrack.Stopped:connect(function()
if TrackStopped then
TrackStopped:disconnect()
end
StopAnimation(value.Animation, true)
TrackEnded.Parent = AnimationMonitor
end)
end
table.insert(Animations, {Animation = value.Animation, AnimationTrack = AnimationTrack, TrackStopped = TrackStopped})
AnimationTrack:Play(value.FadeTime, value.Weight, value.Speed)
if TrackStopped then
AnimationMonitor:WaitForChild(TrackEnded.Name)
end
return TrackEnded.Name
elseif mode == "StopAnimation" and value then
StopAnimation(value.Animation)
end
end
function CheckIfAlive()
return (((Character and Character.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0 and Player and Player.Parent) and true) or false)
end
function Equipped(Mouse)
Character = Tool.Parent
Player = Players:GetPlayerFromCharacter(Character)
Humanoid = Character:FindFirstChild("Humanoid")
ToolEquipped = true
if not CheckIfAlive() then
return
end
Spawn(function()
PlayerMouse = Player:GetMouse()
Mouse.Button1Down:connect(function()
InvokeServer("Button1Click", {Down = true})
end)
Mouse.Button1Up:connect(function()
InvokeServer("Button1Click", {Down = false})
end)
Mouse.KeyDown:connect(function(Key)
InvokeServer("KeyPress", {Key = Key, Down = true})
end)
Mouse.KeyUp:connect(function(Key)
InvokeServer("KeyPress", {Key = Key, Down = false})
end)
for i, v in pairs(Tool:GetChildren()) do
if v:IsA("Animation") then
ContentProvider:Preload(v.AnimationId)
end
end
end)
end
function Unequipped()
for i, v in pairs(Animations) do
if v and v.AnimationTrack then
v.AnimationTrack:Stop()
end
end
Animations = {}
ToolEquipped = false
end
function InvokeServer(mode, value)
local ServerReturn = nil
pcall(function()
ServerReturn = ServerControl:InvokeServer(mode, value)
end)
return ServerReturn
end
function OnClientInvoke(mode, value)
if mode == "PlayAnimation" and value and ToolEquipped and Humanoid then
SetAnimation("PlayAnimation", value)
elseif mode == "StopAnimation" and value then
SetAnimation("StopAnimation", value)
elseif mode == "PlaySound" and value then
value:Play()
elseif mode == "StopSound" and value then
value:Stop()
elseif mode == "MousePosition" then
return {Position = PlayerMouse.Hit.p, Target = PlayerMouse.Target}
end
end
ClientControl.OnClientInvoke = OnClientInvoke
Tool.Equipped:connect(Equipped)
Tool.Unequipped:connect(Unequipped)
|
--// Char Parts |
local Humanoid = char:WaitForChild('Humanoid')
local Head = char:WaitForChild('Head')
local Torso = char:WaitForChild('UpperTorso')
local HumanoidRootPart = char:WaitForChild('HumanoidRootPart')
local RootJoint = char.LowerTorso:WaitForChild('Root')
local Neck = Head:WaitForChild('Neck')
local Right_Shoulder = char.RightUpperArm:WaitForChild('RightShoulder')
local Left_Shoulder = char.LeftUpperArm:WaitForChild('LeftShoulder')
local Right_Hip = char.RightUpperLeg:WaitForChild('RightHip')
local Left_Hip = char.LeftUpperLeg:WaitForChild('LeftHip')
local YOffset = Neck.C0.Y
local WaistYOffset = Neck.C0.Y
local CFNew, CFAng = CFrame.new, CFrame.Angles
local Asin = math.asin
local T = 0.15
User.MouseIconEnabled = true
plr.CameraMode = Enum.CameraMode.Classic
cam.CameraType = Enum.CameraType.Custom
cam.CameraSubject = Humanoid
if gameRules.TeamTags then
local tag = Essential.TeamTag:clone()
tag.Parent = char
tag.Disabled = false
end
function handleAction(actionName, inputState, inputObject)
if actionName == "Fire" and inputState == Enum.UserInputState.Begin and AnimDebounce then
Shoot()
if WeaponData.Type == "Grenade" then
CookGrenade = true
Grenade()
end
elseif actionName == "Fire" and inputState == Enum.UserInputState.End then
mouse1down = false
CookGrenade = false
end
if actionName == "Reload" and inputState == Enum.UserInputState.Begin and AnimDebounce and not CheckingMag and not reloading then
if WeaponData.Jammed then
Jammed()
else
Reload()
end
end
if actionName == "Reload" and inputState == Enum.UserInputState.Begin and reloading and WeaponData.ShellInsert then
CancelReload = true
end
if actionName == "CycleLaser" and inputState == Enum.UserInputState.Begin and LaserAtt then
SetLaser()
end
if actionName == "CycleLight" and inputState == Enum.UserInputState.Begin and TorchAtt then
SetTorch()
end
if actionName == "CycleFiremode" and inputState == Enum.UserInputState.Begin and WeaponData and WeaponData.FireModes.ChangeFiremode then
Firemode()
end
if actionName == "CycleAimpart" and inputState == Enum.UserInputState.Begin then
SetAimpart()
end
if actionName == "ZeroUp" and inputState == Enum.UserInputState.Begin and WeaponData and WeaponData.EnableZeroing then
if WeaponData.CurrentZero < WeaponData.MaxZero then
WeaponInHand.Handle.Click:play()
WeaponData.CurrentZero = math.min(WeaponData.CurrentZero + WeaponData.ZeroIncrement, WeaponData.MaxZero)
UpdateGui()
end
end
if actionName == "ZeroDown" and inputState == Enum.UserInputState.Begin and WeaponData and WeaponData.EnableZeroing then
if WeaponData.CurrentZero > 0 then
WeaponInHand.Handle.Click:play()
WeaponData.CurrentZero = math.max(WeaponData.CurrentZero - WeaponData.ZeroIncrement, 0)
UpdateGui()
end
end
if actionName == "CheckMag" and inputState == Enum.UserInputState.Begin and not CheckingMag and not reloading and not runKeyDown and AnimDebounce then
CheckMagFunction()
end
if actionName == "ToggleBipod" and inputState == Enum.UserInputState.Begin and CanBipod then
BipodActive = not BipodActive
UpdateGui()
end
if actionName == "NVG" and inputState == Enum.UserInputState.Begin and not NVGdebounce then
if plr.Character then
local helmet = plr.Character:FindFirstChild("Helmet")
if helmet then
local nvg = helmet:FindFirstChild("Up")
if nvg then
NVGdebounce = true
delay(.8,function()
NVG = not NVG
Evt.NVG:Fire(NVG)
NVGdebounce = false
end)
end
end
end
end
if actionName == "ADS" and inputState == Enum.UserInputState.Begin and AnimDebounce then
if WeaponData and WeaponData.canAim and GunStance > -2 and not runKeyDown and not CheckingMag then
aimming = not aimming
ADS(aimming)
end
if WeaponData.Type == "Grenade" then
GrenadeMode()
end
end
if actionName == "Stand" and inputState == Enum.UserInputState.Begin and ChangeStance and not Swimming and not Sentado and not runKeyDown then
if Stances == 2 then
Crouched = true
Proned = false
Stances = 1
CameraY = -1
Crouch()
elseif Stances == 1 then
Crouched = false
Stances = 0
CameraY = 0
Stand()
end
end
if actionName == "Crouch" and inputState == Enum.UserInputState.Begin and ChangeStance and not Swimming and not Sentado and not runKeyDown then
if Stances == 0 then
Stances = 1
CameraY = -1
Crouch()
Crouched = true
elseif Stances == 1 then
Stances = 2
CameraX = 0
CameraY = -3.25
Virar = 0
Lean()
Prone()
Crouched = false
Proned = true
end
end
if actionName == "ToggleWalk" and inputState == Enum.UserInputState.Begin and ChangeStance and not runKeyDown then
Steady = not Steady
if Steady then
SE_GUI.MainFrame.Poses.Steady.Visible = true
else
SE_GUI.MainFrame.Poses.Steady.Visible = false
end
if Stances == 0 then
Stand()
end
end
if actionName == "LeanLeft" and inputState == Enum.UserInputState.Begin and Stances ~= 2 and ChangeStance and not Swimming and not runKeyDown and CanLean then
if Virar == 0 or Virar == 1 then
Virar = -1
CameraX = -1.25
else
Virar = 0
CameraX = 0
end
Lean()
end
if actionName == "LeanRight" and inputState == Enum.UserInputState.Begin and Stances ~= 2 and ChangeStance and not Swimming and not runKeyDown and CanLean then
if Virar == 0 or Virar == -1 then
Virar = 1
CameraX = 1.25
else
Virar = 0
CameraX = 0
end
Lean()
end
if actionName == "Run" and inputState == Enum.UserInputState.Begin and running and not script.Parent:GetAttribute("Injured") then
runKeyDown = true
Stand()
Stances = 0
Virar = 0
CameraX = 0
CameraY = 0
Lean()
char:WaitForChild("Humanoid").WalkSpeed = gameRules.RunWalkSpeed
if aimming then
aimming = false
ADS(aimming)
end
if not CheckingMag and not reloading and WeaponData and WeaponData.Type ~= "Grenade" and (GunStance == 0 or GunStance == 2 or GunStance == 3) then
GunStance = 3
Evt.GunStance:FireServer(GunStance,AnimData)
SprintAnim()
end
elseif actionName == "Run" and inputState == Enum.UserInputState.End and runKeyDown then
runKeyDown = false
Stand()
if not CheckingMag and not reloading and WeaponData and WeaponData.Type ~= "Grenade" and (GunStance == 0 or GunStance == 2 or GunStance == 3) then
GunStance = 0
Evt.GunStance:FireServer(GunStance,AnimData)
IdleAnim()
end
end
end
function resetMods()
ModTable.camRecoilMod.RecoilUp = 1
ModTable.camRecoilMod.RecoilLeft = 1
ModTable.camRecoilMod.RecoilRight = 1
ModTable.camRecoilMod.RecoilTilt = 1
ModTable.gunRecoilMod.RecoilUp = 1
ModTable.gunRecoilMod.RecoilTilt = 1
ModTable.gunRecoilMod.RecoilLeft = 1
ModTable.gunRecoilMod.RecoilRight = 1
ModTable.AimRM = 1
ModTable.SpreadRM = 1
ModTable.DamageMod = 1
ModTable.minDamageMod = 1
ModTable.MinRecoilPower = 1
ModTable.MaxRecoilPower = 1
ModTable.RecoilPowerStepAmount = 1
ModTable.MinSpread = 1
ModTable.MaxSpread = 1
ModTable.AimInaccuracyStepAmount = 1
ModTable.AimInaccuracyDecrease = 1
ModTable.WalkMult = 1
ModTable.MuzzleVelocity = 1
end
function setMods(ModData)
ModTable.camRecoilMod.RecoilUp = ModTable.camRecoilMod.RecoilUp * ModData.camRecoil.RecoilUp
ModTable.camRecoilMod.RecoilLeft = ModTable.camRecoilMod.RecoilLeft * ModData.camRecoil.RecoilLeft
ModTable.camRecoilMod.RecoilRight = ModTable.camRecoilMod.RecoilRight * ModData.camRecoil.RecoilRight
ModTable.camRecoilMod.RecoilTilt = ModTable.camRecoilMod.RecoilTilt * ModData.camRecoil.RecoilTilt
ModTable.gunRecoilMod.RecoilUp = ModTable.gunRecoilMod.RecoilUp * ModData.gunRecoil.RecoilUp
ModTable.gunRecoilMod.RecoilTilt = ModTable.gunRecoilMod.RecoilTilt * ModData.gunRecoil.RecoilTilt
ModTable.gunRecoilMod.RecoilLeft = ModTable.gunRecoilMod.RecoilLeft * ModData.gunRecoil.RecoilLeft
ModTable.gunRecoilMod.RecoilRight = ModTable.gunRecoilMod.RecoilRight * ModData.gunRecoil.RecoilRight
ModTable.AimRM = ModTable.AimRM * ModData.AimRecoilReduction
ModTable.SpreadRM = ModTable.SpreadRM * ModData.AimSpreadReduction
ModTable.DamageMod = ModTable.DamageMod * ModData.DamageMod
ModTable.minDamageMod = ModTable.minDamageMod * ModData.minDamageMod
ModTable.MinRecoilPower = ModTable.MinRecoilPower * ModData.MinRecoilPower
ModTable.MaxRecoilPower = ModTable.MaxRecoilPower * ModData.MaxRecoilPower
ModTable.RecoilPowerStepAmount = ModTable.RecoilPowerStepAmount * ModData.RecoilPowerStepAmount
ModTable.MinSpread = ModTable.MinSpread * ModData.MinSpread
ModTable.MaxSpread = ModTable.MaxSpread * ModData.MaxSpread
ModTable.AimInaccuracyStepAmount = ModTable.AimInaccuracyStepAmount * ModData.AimInaccuracyStepAmount
ModTable.AimInaccuracyDecrease = ModTable.AimInaccuracyDecrease * ModData.AimInaccuracyDecrease
ModTable.WalkMult = ModTable.WalkMult * ModData.WalkMult
ModTable.MuzzleVelocity = ModTable.MuzzleVelocity * ModData.MuzzleVelocityMod
end
function loadAttachment(weapon)
if weapon and weapon:FindFirstChild("Nodes") ~= nil then
--load sight Att
if weapon.Nodes:FindFirstChild("Sight") ~= nil and WeaponData.SightAtt ~= "" then
SightData = require(AttModules[WeaponData.SightAtt])
SightAtt = AttModels[WeaponData.SightAtt]:Clone()
SightAtt.Parent = weapon
SightAtt:SetPrimaryPartCFrame(weapon.Nodes.Sight.CFrame)
weapon.AimPart.CFrame = SightAtt.AimPos.CFrame
reticle = SightAtt.SightMark.SurfaceGui.Border.Scope
if SightData.SightZoom > 0 then
ModTable.ZoomValue = SightData.SightZoom
end
if SightData.SightZoom2 > 0 then
ModTable.Zoom2Value = SightData.SightZoom2
end
setMods(SightData)
for index, key in pairs(weapon:GetChildren()) do
if key.Name == "IS" then
key.Transparency = 1
end
end
for index, key in pairs(SightAtt:GetChildren()) do
if key:IsA('BasePart') then
Ultil.Weld(weapon:WaitForChild("Handle"), key )
key.Anchored = false
key.CanCollide = false
end
end
end
--load Barrel Att
if weapon.Nodes:FindFirstChild("Barrel") ~= nil and WeaponData.BarrelAtt ~= "" then
BarrelData = require(AttModules[WeaponData.BarrelAtt])
BarrelAtt = AttModels[WeaponData.BarrelAtt]:Clone()
BarrelAtt.Parent = weapon
BarrelAtt:SetPrimaryPartCFrame(weapon.Nodes.Barrel.CFrame)
if BarrelAtt:FindFirstChild("BarrelPos") ~= nil then
weapon.Handle.Muzzle.WorldCFrame = BarrelAtt.BarrelPos.CFrame
end
Suppressor = BarrelData.IsSuppressor
FlashHider = BarrelData.IsFlashHider
setMods(BarrelData)
for index, key in pairs(BarrelAtt:GetChildren()) do
if key:IsA('BasePart') then
Ultil.Weld(weapon:WaitForChild("Handle"), key )
key.Anchored = false
key.CanCollide = false
end
end
end
--load Under Barrel Att
if weapon.Nodes:FindFirstChild("UnderBarrel") ~= nil and WeaponData.UnderBarrelAtt ~= "" then
UnderBarrelData = require(AttModules[WeaponData.UnderBarrelAtt])
UnderBarrelAtt = AttModels[WeaponData.UnderBarrelAtt]:Clone()
UnderBarrelAtt.Parent = weapon
UnderBarrelAtt:SetPrimaryPartCFrame(weapon.Nodes.UnderBarrel.CFrame)
setMods(UnderBarrelData)
BipodAtt = UnderBarrelData.IsBipod
if BipodAtt then
CAS:BindAction("ToggleBipod", handleAction, true, Enum.KeyCode.B)
end
for index, key in pairs(UnderBarrelAtt:GetChildren()) do
if key:IsA('BasePart') then
Ultil.Weld(weapon:WaitForChild("Handle"), key )
key.Anchored = false
key.CanCollide = false
end
end
end
if weapon.Nodes:FindFirstChild("Other") ~= nil and WeaponData.OtherAtt ~= "" then
OtherData = require(AttModules[WeaponData.OtherAtt])
OtherAtt = AttModels[WeaponData.OtherAtt]:Clone()
OtherAtt.Parent = weapon
OtherAtt:SetPrimaryPartCFrame(weapon.Nodes.Other.CFrame)
setMods(OtherData)
LaserAtt = OtherData.EnableLaser
TorchAtt = OtherData.EnableFlashlight
if OtherData.InfraRed then
IREnable = true
end
for index, key in pairs(OtherAtt:GetChildren()) do
if key:IsA('BasePart') then
Ultil.Weld(weapon:WaitForChild("Handle"), key )
key.Anchored = false
key.CanCollide = false
end
end
end
end
end
function SetLaser()
if gameRules.RealisticLaser and IREnable then
if not LaserActive and not IRmode then
LaserActive = true
IRmode = true
elseif LaserActive and IRmode then
IRmode = false
else
LaserActive = false
IRmode = false
end
else
LaserActive = not LaserActive
end
print(LaserActive, IRmode)
if LaserActive then
if not Pointer then
for index, Key in pairs(WeaponInHand:GetDescendants()) do
if Key:IsA("BasePart") and Key.Name == "LaserPoint" then
local LaserPointer = Instance.new('Part',Key)
LaserPointer.Shape = 'Ball'
LaserPointer.Size = Vector3.new(0.2, 0.2, 0.2)
LaserPointer.CanCollide = false
LaserPointer.Color = Key.Color
LaserPointer.Material = Enum.Material.Neon
local LaserSP = Instance.new('Attachment',Key)
local LaserEP = Instance.new('Attachment',LaserPointer)
local Laser = Instance.new('Beam',LaserPointer)
Laser.Transparency = NumberSequence.new(0)
Laser.LightEmission = 1
Laser.LightInfluence = 1
Laser.Attachment0 = LaserSP
Laser.Attachment1 = LaserEP
Laser.Color = ColorSequence.new(Key.Color)
Laser.FaceCamera = true
Laser.Width0 = 0.01
Laser.Width1 = 0.01
if gameRules.RealisticLaser then
Laser.Enabled = false
end
Pointer = LaserPointer
break
end
end
end
else
for index, Key in pairs(WeaponInHand:GetDescendants()) do
if Key:IsA("BasePart") and Key.Name == "LaserPoint" then
Key:ClearAllChildren()
break
end
end
Pointer = nil
if gameRules.ReplicatedLaser then
Evt.SVLaser:FireServer(nil,2,nil,false,WeaponTool)
end
end
WeaponInHand.Handle.Click:play()
UpdateGui()
end
function SetTorch()
TorchActive = not TorchActive
if TorchActive then
for index, Key in pairs(WeaponInHand:GetDescendants()) do
if Key:IsA("BasePart") and Key.Name == "FlashPoint" then
Key.Light.Enabled = true
end
end
else
for index, Key in pairs(WeaponInHand:GetDescendants()) do
if Key:IsA("BasePart") and Key.Name == "FlashPoint" then
Key.Light.Enabled = false
end
end
end
Evt.SVFlash:FireServer(WeaponTool,TorchActive)
WeaponInHand.Handle.Click:play()
UpdateGui()
end
function ADS(aimming)
if WeaponData and WeaponInHand then
if aimming then
if SafeMode then
SafeMode = false
GunStance = 0
IdleAnim()
UpdateGui()
end
game:GetService('UserInputService').MouseDeltaSensitivity = (Sens/100)
WeaponInHand.Handle.AimDown:Play()
GunStance = 2
Evt.GunStance:FireServer(GunStance,AnimData)
TS:Create(Crosshair.Up, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 1}):Play()
TS:Create(Crosshair.Down, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 1}):Play()
TS:Create(Crosshair.Left, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 1}):Play()
TS:Create(Crosshair.Right, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 1}):Play()
TS:Create(Crosshair.Center, TweenInfo.new(.2,Enum.EasingStyle.Linear), {ImageTransparency = 1}):Play()
else
game:GetService('UserInputService').MouseDeltaSensitivity = 1
WeaponInHand.Handle.AimUp:Play()
GunStance = 0
Evt.GunStance:FireServer(GunStance,AnimData)
if WeaponData.CrossHair then
TS:Create(Crosshair.Up, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 0}):Play()
TS:Create(Crosshair.Down, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 0}):Play()
TS:Create(Crosshair.Left, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 0}):Play()
TS:Create(Crosshair.Right, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 0}):Play()
end
if WeaponData.CenterDot then
TS:Create(Crosshair.Center, TweenInfo.new(.2,Enum.EasingStyle.Linear), {ImageTransparency = 0}):Play()
else
TS:Create(Crosshair.Center, TweenInfo.new(.2,Enum.EasingStyle.Linear), {ImageTransparency = 1}):Play()
end
end
end
end
function SetAimpart()
if aimming then
if AimPartMode == 1 then
AimPartMode = 2
if WeaponInHand:FindFirstChild('AimPart2') then
CurAimpart = WeaponInHand:FindFirstChild('AimPart2')
end
else
AimPartMode = 1
CurAimpart = WeaponInHand:FindFirstChild('AimPart')
end
--print("Set to Aimpart: "..AimPartMode)
end
end
function Firemode()
WeaponInHand.Handle.SafetyClick:Play()
mouse1down = false
---Semi Settings---
if WeaponData.ShootType == 1 and WeaponData.FireModes.Burst == true then
WeaponData.ShootType = 2
elseif WeaponData.ShootType == 1 and WeaponData.FireModes.Burst == false and WeaponData.FireModes.Auto == true then
WeaponData.ShootType = 3
---Burst Settings---
elseif WeaponData.ShootType == 2 and WeaponData.FireModes.Auto == true then
WeaponData.ShootType = 3
elseif WeaponData.ShootType == 2 and WeaponData.FireModes.Semi == true and WeaponData.FireModes.Auto == false then
WeaponData.ShootType = 1
---Auto Settings---
elseif WeaponData.ShootType == 3 and WeaponData.FireModes.Semi == true then
WeaponData.ShootType = 1
elseif WeaponData.ShootType == 3 and WeaponData.FireModes.Semi == false and WeaponData.FireModes.Burst == true then
WeaponData.ShootType = 2
---Explosive Settings---
end
UpdateGui()
end
function setup(Tool)
if char and char:WaitForChild("Humanoid").Health > 0 and Tool ~= nil then
ToolEquip = true
User.MouseIconEnabled = false
plr.CameraMode = Enum.CameraMode.LockFirstPerson
WeaponTool = Tool
WeaponData = require(Tool:WaitForChild("ACS_Settings"))
AnimData = require(Tool:WaitForChild("ACS_Animations"))
WeaponInHand = GunModels:WaitForChild(Tool.Name):Clone()
WeaponInHand.PrimaryPart = WeaponInHand:WaitForChild("Handle")
Evt.Equip:FireServer(Tool,1,WeaponData,AnimData)
ViewModel = ArmModel:WaitForChild("Arms"):Clone()
ViewModel.Name = "Viewmodel"
if char:FindFirstChild("Body Colors") ~= nil then
local Colors = char:WaitForChild("Body Colors"):Clone()
Colors.Parent = ViewModel
end
if char:FindFirstChild("Shirt") ~= nil then
local Shirt = char:FindFirstChild("Shirt"):Clone()
Shirt.Parent = ViewModel
end
AnimPart = Instance.new("Part",ViewModel)
AnimPart.Size = Vector3.new(0.1,0.1,0.1)
AnimPart.Anchored = true
AnimPart.CanCollide = false
AnimPart.Transparency = 1
ViewModel.PrimaryPart = AnimPart
LArmWeld = Instance.new("Motor6D",AnimPart)
LArmWeld.Name = "LeftArm"
LArmWeld.Part0 = AnimPart
RArmWeld = Instance.new("Motor6D",AnimPart)
RArmWeld.Name = "RightArm"
RArmWeld.Part0 = AnimPart
GunWeld = Instance.new("Motor6D",AnimPart)
GunWeld.Name = "Handle"
--setup arms to camera
ViewModel.Parent = cam
maincf = AnimData.MainCFrame
guncf = AnimData.GunCFrame
larmcf = AnimData.LArmCFrame
rarmcf = AnimData.RArmCFrame
if WeaponData.CrossHair then
TS:Create(Crosshair.Up, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 0}):Play()
TS:Create(Crosshair.Down, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 0}):Play()
TS:Create(Crosshair.Left, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 0}):Play()
TS:Create(Crosshair.Right, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 0}):Play()
if WeaponData.Bullets > 1 then
Crosshair.Up.Rotation = 90
Crosshair.Down.Rotation = 90
Crosshair.Left.Rotation = 90
Crosshair.Right.Rotation = 90
else
Crosshair.Up.Rotation = 0
Crosshair.Down.Rotation = 0
Crosshair.Left.Rotation = 0
Crosshair.Right.Rotation = 0
end
else
TS:Create(Crosshair.Up, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 1}):Play()
TS:Create(Crosshair.Down, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 1}):Play()
TS:Create(Crosshair.Left, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 1}):Play()
TS:Create(Crosshair.Right, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 1}):Play()
end
if WeaponData.CenterDot then
TS:Create(Crosshair.Center, TweenInfo.new(.2,Enum.EasingStyle.Linear), {ImageTransparency = 0}):Play()
else
TS:Create(Crosshair.Center, TweenInfo.new(.2,Enum.EasingStyle.Linear), {ImageTransparency = 1}):Play()
end
LArm = ViewModel:WaitForChild("Left Arm")
LArmWeld.Part1 = LArm
LArmWeld.C0 = CFrame.new()
LArmWeld.C1 = CFrame.new(1,-1,-5) * CFrame.Angles(math.rad(0),math.rad(0),math.rad(0)):inverse()
RArm = ViewModel:WaitForChild("Right Arm")
RArmWeld.Part1 = RArm
RArmWeld.C0 = CFrame.new()
RArmWeld.C1 = CFrame.new(-1,-1,-5) * CFrame.Angles(math.rad(0),math.rad(0),math.rad(0)):inverse()
GunWeld.Part0 = RArm
LArm.Anchored = false
RArm.Anchored = false
--setup weapon to camera
ModTable.ZoomValue = WeaponData.Zoom
ModTable.Zoom2Value = WeaponData.Zoom2
IREnable = WeaponData.InfraRed
CAS:BindAction("Fire", handleAction, true, Enum.UserInputType.MouseButton1, Enum.KeyCode.ButtonR2)
CAS:BindAction("ADS", handleAction, true, Enum.UserInputType.MouseButton2, Enum.KeyCode.ButtonL2)
CAS:BindAction("Reload", handleAction, true, Enum.KeyCode.R, Enum.KeyCode.ButtonB)
CAS:BindAction("CycleAimpart", handleAction, false, Enum.KeyCode.T)
CAS:BindAction("CycleLaser", handleAction, true, Enum.KeyCode.H)
CAS:BindAction("CycleLight", handleAction, true, Enum.KeyCode.J)
CAS:BindAction("CycleFiremode", handleAction, false, Enum.KeyCode.V)
CAS:BindAction("CheckMag", handleAction, false, Enum.KeyCode.M)
CAS:BindAction("ZeroDown", handleAction, false, Enum.KeyCode.LeftBracket)
CAS:BindAction("ZeroUp", handleAction, false, Enum.KeyCode.RightBracket)
loadAttachment(WeaponInHand)
BSpread = math.min(WeaponData.MinSpread * ModTable.MinSpread, WeaponData.MaxSpread * ModTable.MaxSpread)
RecoilPower = math.min(WeaponData.MinRecoilPower * ModTable.MinRecoilPower, WeaponData.MaxRecoilPower * ModTable.MaxRecoilPower)
Ammo = WeaponData.AmmoInGun
StoredAmmo = WeaponData.StoredAmmo
CurAimpart = WeaponInHand:FindFirstChild("AimPart")
for index, Key in pairs(WeaponInHand:GetDescendants()) do
if Key:IsA("BasePart") and Key.Name == "FlashPoint" then
TorchAtt = true
end
if Key:IsA("BasePart") and Key.Name == "LaserPoint" then
LaserAtt = true
end
end
if WeaponData.EnableHUD then
SE_GUI.GunHUD.Visible = true
end
UpdateGui()
for index, key in pairs(WeaponInHand:GetChildren()) do
if key:IsA('BasePart') and key.Name ~= 'Handle' then
if key.Name ~= "Bolt" and key.Name ~= 'Lid' and key.Name ~= "Slide" then
Ultil.Weld(WeaponInHand:WaitForChild("Handle"), key)
end
if key.Name == "Bolt" or key.Name == "Slide" then
Ultil.WeldComplex(WeaponInHand:WaitForChild("Handle"), key, key.Name)
end;
if key.Name == "Lid" then
if WeaponInHand:FindFirstChild('LidHinge') then
Ultil.Weld(key, WeaponInHand:WaitForChild("LidHinge"))
else
Ultil.Weld(key, WeaponInHand:WaitForChild("Handle"))
end
end
end
end;
for L_213_forvar1, L_214_forvar2 in pairs(WeaponInHand:GetChildren()) do
if L_214_forvar2:IsA('BasePart') then
L_214_forvar2.Anchored = false
L_214_forvar2.CanCollide = false
end
end;
if WeaponInHand:FindFirstChild("Nodes") then
for L_213_forvar1, L_214_forvar2 in pairs(WeaponInHand.Nodes:GetChildren()) do
if L_214_forvar2:IsA('BasePart') then
Ultil.Weld(WeaponInHand:WaitForChild("Handle"), L_214_forvar2)
L_214_forvar2.Anchored = false
L_214_forvar2.CanCollide = false
end
end;
end
GunWeld.Part1 = WeaponInHand:WaitForChild("Handle")
GunWeld.C1 = guncf
--WeaponInHand:SetPrimaryPartCFrame( RArm.CFrame * guncf)
WeaponInHand.Parent = ViewModel
if Ammo <= 0 and WeaponData.Type == "Gun" then
WeaponInHand.Handle.Slide.C0 = WeaponData.SlideEx:inverse()
end
EquipAnim()
if WeaponData and WeaponData.Type ~= "Grenade" then
RunCheck()
end
end
end
function unset()
ToolEquip = false
Evt.Equip:FireServer(WeaponTool,2)
--unsetup weapon data module
CAS:UnbindAction("Fire")
CAS:UnbindAction("ADS")
CAS:UnbindAction("Reload")
CAS:UnbindAction("CycleLaser")
CAS:UnbindAction("CycleLight")
CAS:UnbindAction("CycleFiremode")
CAS:UnbindAction("CycleAimpart")
CAS:UnbindAction("ZeroUp")
CAS:UnbindAction("ZeroDown")
CAS:UnbindAction("CheckMag")
mouse1down = false
aimming = false
TS:Create(cam,AimTween,{FieldOfView = 70}):Play()
TS:Create(Crosshair.Up, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 1}):Play()
TS:Create(Crosshair.Down, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 1}):Play()
TS:Create(Crosshair.Left, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 1}):Play()
TS:Create(Crosshair.Right, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 1}):Play()
TS:Create(Crosshair.Center, TweenInfo.new(.2,Enum.EasingStyle.Linear), {ImageTransparency = 1}):Play()
User.MouseIconEnabled = true
game:GetService('UserInputService').MouseDeltaSensitivity = 1
cam.CameraType = Enum.CameraType.Custom
plr.CameraMode = Enum.CameraMode.Classic
if WeaponInHand then
WeaponData.AmmoInGun = Ammo
WeaponData.StoredAmmo = StoredAmmo
ViewModel:Destroy()
ViewModel = nil
WeaponInHand = nil
WeaponTool = nil
LArm = nil
RArm = nil
LArmWeld = nil
RArmWeld = nil
WeaponData = nil
AnimData = nil
SightAtt = nil
reticle = nil
BarrelAtt = nil
UnderBarrelAtt = nil
OtherAtt = nil
LaserAtt = false
LaserActive = false
IRmode = false
TorchAtt = false
TorchActive = false
BipodAtt = false
BipodActive = false
LaserDist = 0
Pointer = nil
BSpread = nil
RecoilPower = nil
Suppressor = false
FlashHider = false
CancelReload = false
reloading = false
SafeMode = false
CheckingMag = false
GRDebounce = false
CookGrenade = false
GunStance = 0
resetMods()
generateBullet = 1
AimPartMode = 1
SE_GUI.GunHUD.Visible = false
SE_GUI.GrenadeForce.Visible = false
BipodCF = CFrame.new()
if gameRules.ReplicatedLaser then
Evt.SVLaser:FireServer(nil,2,nil,false,WeaponTool)
end
end
end
local HalfStep = false
function HeadMovement()
if char.Humanoid.Health > 0 then
local CameraDirection = char.HumanoidRootPart.CFrame:toObjectSpace(cam.CFrame).lookVector
if Neck then
if char.Humanoid.RigType == Enum.HumanoidRigType.R15 and char.Humanoid.Health > 0 and char.Humanoid.PlatformStand == false then
HalfStep = not HalfStep
local neckCFrame = CFNew(0, YOffset, 0) * CFAng(-Asin(char.UpperTorso.CFrame.lookVector.Y), -Asin(CameraDirection.X/1.15), 0) * CFAng(Asin(CameraDirection.Y), 0, 0)
TS:Create(Neck, TweenInfo.new(.2, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {C0 = neckCFrame}):Play()
if HalfStep then
Evt.HeadRot:FireServer(neckCFrame)
end
end
end
end
end
function renderCam()
cam.CFrame = cam.CFrame*CFrame.Angles(cameraspring.p.x,cameraspring.p.y,cameraspring.p.z)
end
function renderGunRecoil()
recoilcf = recoilcf*CFrame.Angles(RecoilSpring.p.x,RecoilSpring.p.y,RecoilSpring.p.z)
end
function Recoil()
local vr = (math.random(WeaponData.camRecoil.camRecoilUp[1], WeaponData.camRecoil.camRecoilUp[2])/2) * ModTable.camRecoilMod.RecoilUp
local lr = (math.random(WeaponData.camRecoil.camRecoilLeft[1], WeaponData.camRecoil.camRecoilLeft[2])) * ModTable.camRecoilMod.RecoilLeft
local rr = (math.random(WeaponData.camRecoil.camRecoilRight[1], WeaponData.camRecoil.camRecoilRight[2])) * ModTable.camRecoilMod.RecoilRight
local hr = (math.random(-rr, lr)/2)
local tr = (math.random(WeaponData.camRecoil.camRecoilTilt[1], WeaponData.camRecoil.camRecoilTilt[2])/2) * ModTable.camRecoilMod.RecoilTilt
local RecoilX = math.rad(vr * RAND( 1, 1, .1))
local RecoilY = math.rad(hr * RAND(-1, 1, .1))
local RecoilZ = math.rad(tr * RAND(-1, 1, .1))
local gvr = (math.random(WeaponData.gunRecoil.gunRecoilUp[1], WeaponData.gunRecoil.gunRecoilUp[2]) /10) * ModTable.gunRecoilMod.RecoilUp
local gdr = (math.random(-1,1) * math.random(WeaponData.gunRecoil.gunRecoilTilt[1], WeaponData.gunRecoil.gunRecoilTilt[2]) /10) * ModTable.gunRecoilMod.RecoilTilt
local glr = (math.random(WeaponData.gunRecoil.gunRecoilLeft[1], WeaponData.gunRecoil.gunRecoilLeft[2])) * ModTable.gunRecoilMod.RecoilLeft
local grr = (math.random(WeaponData.gunRecoil.gunRecoilRight[1], WeaponData.gunRecoil.gunRecoilRight[2])) * ModTable.gunRecoilMod.RecoilRight
local ghr = (math.random(-grr, glr)/10)
local ARR = WeaponData.AimRecoilReduction * ModTable.AimRM
if BipodActive then
cameraspring:accelerate(Vector3.new( RecoilX, RecoilY/2, 0 ))
if not aimming then
RecoilSpring:accelerate(Vector3.new( math.rad(.25 * gvr * RecoilPower), math.rad(.25 * ghr * RecoilPower), math.rad(.25 * gdr)))
recoilcf = recoilcf * CFrame.new(0,0,.1) * CFrame.Angles( math.rad(.25 * gvr * RecoilPower ),math.rad(.25 * ghr * RecoilPower ),math.rad(.25 * gdr * RecoilPower ))
else
RecoilSpring:accelerate(Vector3.new( math.rad( .25 * gvr * RecoilPower/ARR) , math.rad(.25 * ghr * RecoilPower/ARR), math.rad(.25 * gdr/ ARR)))
recoilcf = recoilcf * CFrame.new(0,0,.1) * CFrame.Angles( math.rad(.25 * gvr * RecoilPower/ARR ),math.rad(.25 * ghr * RecoilPower/ARR ),math.rad(.25 * gdr * RecoilPower/ARR ))
end
Thread:Wait(0.05)
cameraspring:accelerate(Vector3.new(-RecoilX, -RecoilY/2, 0))
else
cameraspring:accelerate(Vector3.new( RecoilX , RecoilY, RecoilZ ))
if not aimming then
RecoilSpring:accelerate(Vector3.new( math.rad(gvr * RecoilPower), math.rad(ghr * RecoilPower), math.rad(gdr)))
recoilcf = recoilcf * CFrame.new(0,-0.05,.1) * CFrame.Angles( math.rad( gvr * RecoilPower ),math.rad( ghr * RecoilPower ),math.rad( gdr * RecoilPower ))
else
RecoilSpring:accelerate(Vector3.new( math.rad(gvr * RecoilPower/ARR) , math.rad(ghr * RecoilPower/ARR), math.rad(gdr/ ARR)))
recoilcf = recoilcf * CFrame.new(0,0,.1) * CFrame.Angles( math.rad( gvr * RecoilPower/ARR ),math.rad( ghr * RecoilPower/ARR ),math.rad( gdr * RecoilPower/ARR ))
end
end
end
function CheckForHumanoid(L_225_arg1)
local L_226_ = false
local L_227_ = nil
if L_225_arg1 then
if (L_225_arg1.Parent:FindFirstChildOfClass("Humanoid") or L_225_arg1.Parent.Parent:FindFirstChildOfClass("Humanoid")) then
L_226_ = true
if L_225_arg1.Parent:FindFirstChildOfClass('Humanoid') then
L_227_ = L_225_arg1.Parent:FindFirstChildOfClass('Humanoid')
elseif L_225_arg1.Parent.Parent:FindFirstChildOfClass('Humanoid') then
L_227_ = L_225_arg1.Parent.Parent:FindFirstChildOfClass('Humanoid')
end
else
L_226_ = false
end
end
return L_226_, L_227_
end
function CastRay(Bullet, Origin)
if Bullet then
local Bpos = Bullet.Position
local Bpos2 = cam.CFrame.Position
local recast = false
local TotalDistTraveled = 0
local Debounce = false
local raycastResult
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = Ignore_Model
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.IgnoreWater = true
while Bullet do
Run.Heartbeat:Wait()
if Bullet.Parent ~= nil then
Bpos = Bullet.Position
TotalDistTraveled = (Bullet.Position - Origin).Magnitude
if TotalDistTraveled > 7000 then
Bullet:Destroy()
Debounce = true
break
end
for _, plyr in pairs(game.Players:GetChildren()) do
if not Debounce and plyr:IsA('Player') and plyr ~= plr and plyr.Character and plyr.Character:FindFirstChild('Head') ~= nil and (plyr.Character.Head.Position - Bpos).magnitude <= 25 then
Evt.Whizz:FireServer(plyr)
Evt.Suppression:FireServer(plyr,1,nil,nil)
Debounce = true
end
end
-- Set an origin and directional vector
raycastResult = workspace:Raycast(Bpos2, (Bpos - Bpos2) * 1, raycastParams)
recast = false
if raycastResult then
local Hit2 = raycastResult.Instance
if Hit2 and Hit2.Parent:IsA('Accessory') or Hit2.Parent:IsA('Hat') then
for _,players in pairs(game.Players:GetPlayers()) do
if players.Character then
for i, hats in pairs(players.Character:GetChildren()) do
if hats:IsA("Accessory") then
table.insert(Ignore_Model, hats)
end
end
end
end
recast = true
CastRay(Bullet, Origin)
break
end
if Hit2 and Hit2.Name == "Ignorable" or Hit2.Name == "Glass" or Hit2.Name == "Ignore" or Hit2.Parent.Name == "Top" or Hit2.Parent.Name == "Helmet" or Hit2.Parent.Name == "Up" or Hit2.Parent.Name == "Down" or Hit2.Parent.Name == "Face" or Hit2.Parent.Name == "Olho" or Hit2.Parent.Name == "Headset" or Hit2.Parent.Name == "Numero" or Hit2.Parent.Name == "Vest" or Hit2.Parent.Name == "Chest" or Hit2.Parent.Name == "Waist" or Hit2.Parent.Name == "Back" or Hit2.Parent.Name == "Belt" or Hit2.Parent.Name == "Leg1" or Hit2.Parent.Name == "Leg2" or Hit2.Parent.Name == "Arm1" or Hit2.Parent.Name == "Arm2" then
table.insert(Ignore_Model, Hit2)
recast = true
CastRay(Bullet, Origin)
break
end
if Hit2 and Hit2.Parent.Name == "Top" or Hit2.Parent.Name == "Helmet" or Hit2.Parent.Name == "Up" or Hit2.Parent.Name == "Down" or Hit2.Parent.Name == "Face" or Hit2.Parent.Name == "Olho" or Hit2.Parent.Name == "Headset" or Hit2.Parent.Name == "Numero" or Hit2.Parent.Name == "Vest" or Hit2.Parent.Name == "Chest" or Hit2.Parent.Name == "Waist" or Hit2.Parent.Name == "Back" or Hit2.Parent.Name == "Belt" or Hit2.Parent.Name == "Leg1" or Hit2.Parent.Name == "Leg2" or Hit2.Parent.Name == "Arm1" or Hit2.Parent.Name == "Arm2" then
table.insert(Ignore_Model, Hit2.Parent)
recast = true
CastRay(Bullet, Origin)
break
end
if Hit2 and (Hit2.Transparency >= 1 or Hit2.CanCollide == false) and Hit2.Name ~= 'Head' and Hit2.Name ~= 'Right Arm' and Hit2.Name ~= 'Left Arm' and Hit2.Name ~= 'Right Leg' and Hit2.Name ~= 'Left Leg' and Hit2.Name ~= "UpperTorso" and Hit2.Name ~= "LowerTorso" and Hit2.Name ~= "RightUpperArm" and Hit2.Name ~= "RightLowerArm" and Hit2.Name ~= "RightHand" and Hit2.Name ~= "LeftUpperArm" and Hit2.Name ~= "LeftLowerArm" and Hit2.Name ~= "LeftHand" and Hit2.Name ~= "RightUpperLeg" and Hit2.Name ~= "RightLowerLeg" and Hit2.Name ~= "RightFoot" and Hit2.Name ~= "LeftUpperLeg" and Hit2.Name ~= "LeftLowerLeg" and Hit2.Name ~= "LeftFoot" and Hit2.Name ~= 'Armor' and Hit2.Name ~= 'EShield' then
table.insert(Ignore_Model, Hit2)
recast = true
CastRay(Bullet, Origin)
break
end
if not recast then
Bullet:Destroy()
Debounce = true
local FoundHuman,VitimaHuman = CheckForHumanoid(raycastResult.Instance)
HitMod.HitEffect(Ignore_Model, raycastResult.Position, raycastResult.Instance , raycastResult.Normal, raycastResult.Material, WeaponData)
Evt.HitEffect:FireServer(raycastResult.Position, raycastResult.Instance , raycastResult.Normal, raycastResult.Material, WeaponData)
local HitPart = raycastResult.Instance
TotalDistTraveled = (raycastResult.Position - Origin).Magnitude
if FoundHuman == true and VitimaHuman.Health > 0 and WeaponData then
local SKP_02 = SKP_01.."-"..plr.UserId
if HitPart.Name == "Head" or HitPart.Parent.Name == "Top" or HitPart.Parent.Name == "Headset" or HitPart.Parent.Name == "Olho" or HitPart.Parent.Name == "Face" or HitPart.Parent.Name == "Numero" then
Evt.Damage:InvokeServer(WeaponTool, VitimaHuman, TotalDistTraveled, 1, WeaponData, ModTable, nil, nil, SKP_02)
elseif HitPart.Name == "Torso" or HitPart.Name == "UpperTorso" or HitPart.Name == "LowerTorso" or HitPart.Parent.Name == "Chest" or HitPart.Parent.Name == "Waist" or HitPart.Name == "Right Arm" or HitPart.Name == "Left Arm" or HitPart.Name == "RightUpperArm" or HitPart.Name == "RightLowerArm" or HitPart.Name == "RightHand" or HitPart.Name == "LeftUpperArm" or HitPart.Name == "LeftLowerArm" or HitPart.Name == "LeftHand" then
Evt.Damage:InvokeServer(WeaponTool, VitimaHuman, TotalDistTraveled, 2, WeaponData, ModTable, nil, nil, SKP_02)
elseif HitPart.Name == "Right Leg" or HitPart.Name == "Left Leg" or HitPart.Name == "RightUpperLeg" or HitPart.Name == "RightLowerLeg" or HitPart.Name == "RightFoot" or HitPart.Name == "LeftUpperLeg" or HitPart.Name == "LeftLowerLeg" or HitPart.Name == "LeftFoot" then
Evt.Damage:InvokeServer(WeaponTool, VitimaHuman, TotalDistTraveled, 3, WeaponData, ModTable, nil, nil, SKP_02)
end
end
end
break
end
Bpos2 = Bpos
else
break
end
end
end
end
local Tracers = 0
function TracerCalculation()
if WeaponData.Tracer or WeaponData.BulletFlare then
if WeaponData.RandomTracer.Enabled then
if (math.random(1, 100) <= WeaponData.RandomTracer.Chance) then
return true
else
return false
end
else
if Tracers >= WeaponData.TracerEveryXShots then
Tracers = 0
return true
else
Tracers = Tracers + 1
return false
end
end
end
end
function CreateBullet()
local Bullet = Instance.new("Part",ACS_Workspace.Client)
Bullet.Name = plr.Name.."_Bullet"
Bullet.CanCollide = false
Bullet.Shape = Enum.PartType.Ball
Bullet.Transparency = 1
Bullet.Size = Vector3.new(1,1,1)
local Origin = WeaponInHand.Handle.Muzzle.WorldPosition
local Direction = WeaponInHand.Handle.Muzzle.WorldCFrame.LookVector + (WeaponInHand.Handle.Muzzle.WorldCFrame.UpVector * (((WeaponData.BulletDrop * WeaponData.CurrentZero/4)/WeaponData.MuzzleVelocity))/2)
local BulletCF = CFrame.new(Origin, Direction)
local WalkMul = WeaponData.WalkMult * ModTable.WalkMult
local BColor = Color3.fromRGB(255,255,255)
local balaspread
if aimming and WeaponData.Bullets <= 1 then
balaspread = CFrame.Angles(
math.rad(RAND(-BSpread - (charspeed/1) * WalkMul, BSpread + (charspeed/1) * WalkMul) / (10 * WeaponData.AimSpreadReduction)),
math.rad(RAND(-BSpread - (charspeed/1) * WalkMul, BSpread + (charspeed/1) * WalkMul) / (10 * WeaponData.AimSpreadReduction)),
math.rad(RAND(-BSpread - (charspeed/1) * WalkMul, BSpread + (charspeed/1) * WalkMul) / (10 * WeaponData.AimSpreadReduction))
)
else
balaspread = CFrame.Angles(
math.rad(RAND(-BSpread - (charspeed/1) * WalkMul, BSpread + (charspeed/1) * WalkMul) / 10),
math.rad(RAND(-BSpread - (charspeed/1) * WalkMul, BSpread + (charspeed/1) * WalkMul) / 10),
math.rad(RAND(-BSpread - (charspeed/1) * WalkMul, BSpread + (charspeed/1) * WalkMul) / 10)
)
end
Direction = balaspread * Direction
local Visivel = TracerCalculation()
if WeaponData.RainbowMode then
BColor = Color3.fromRGB(math.random(0,255),math.random(0,255),math.random(0,255))
else
BColor = WeaponData.TracerColor
end
if Visivel then
if gameRules.ReplicatedBullets then
Evt.ServerBullet:FireServer(Origin,Direction,WeaponData,ModTable)
end
if WeaponData.Tracer == true then
local At1 = Instance.new("Attachment")
At1.Name = "At1"
At1.Position = Vector3.new(-(.05),0,0)
At1.Parent = Bullet
local At2 = Instance.new("Attachment")
At2.Name = "At2"
At2.Position = Vector3.new((.05),0,0)
At2.Parent = Bullet
local Particles = Instance.new("Trail")
Particles.Transparency = NumberSequence.new({
NumberSequenceKeypoint.new(0, 0, 0);
NumberSequenceKeypoint.new(1, 1);
}
)
Particles.WidthScale = NumberSequence.new({
NumberSequenceKeypoint.new(0, 2, 0);
NumberSequenceKeypoint.new(1, 1);
}
)
Particles.Color = ColorSequence.new(BColor)
Particles.Texture = "rbxassetid://232918622"
Particles.TextureMode = Enum.TextureMode.Stretch
Particles.FaceCamera = true
Particles.LightEmission = 1
Particles.LightInfluence = 0
Particles.Lifetime = .25
Particles.Attachment0 = At1
Particles.Attachment1 = At2
Particles.Parent = Bullet
end
if WeaponData.BulletFlare == true then
local bg = Instance.new("BillboardGui", Bullet)
bg.Adornee = Bullet
bg.Enabled = false
local flashsize = math.random(275, 375)/10
bg.Size = UDim2.new(flashsize, 0, flashsize, 0)
bg.LightInfluence = 0
local flash = Instance.new("ImageLabel", bg)
flash.BackgroundTransparency = 1
flash.Size = UDim2.new(1, 0, 1, 0)
flash.Position = UDim2.new(0, 0, 0, 0)
flash.Image = "http://www.roblox.com/asset/?id=1047066405"
flash.ImageTransparency = math.random(2, 5)/15
flash.ImageColor3 = BColor
spawn(function()
wait(.1)
if Bullet:FindFirstChild("BillboardGui") ~= nil then
Bullet.BillboardGui.Enabled = true
end
end)
end
end
local BulletMass = Bullet:GetMass()
local Force = Vector3.new(0,BulletMass * (196.2) - (WeaponData.BulletDrop) * (196.2), 0)
local BF = Instance.new("BodyForce",Bullet)
Bullet.CFrame = BulletCF
Bullet:ApplyImpulse(Direction * WeaponData.MuzzleVelocity * ModTable.MuzzleVelocity)
BF.Force = Force
game.Debris:AddItem(Bullet, 5)
CastRay(Bullet, Origin)
end
function meleeCast()
local recast
-- Set an origin and directional vector
local rayOrigin = cam.CFrame.Position
local rayDirection = cam.CFrame.LookVector * WeaponData.BladeRange
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = Ignore_Model
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.IgnoreWater = true
local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycastParams)
if raycastResult then
local Hit2 = raycastResult.Instance
--Check if it's a hat or accessory
if Hit2 and Hit2.Parent:IsA('Accessory') or Hit2.Parent:IsA('Hat') then
for _,players in pairs(game.Players:GetPlayers()) do
if players.Character then
for i, hats in pairs(players.Character:GetChildren()) do
if hats:IsA("Accessory") then
table.insert(Ignore_Model, hats)
end
end
end
end
return meleeCast()
end
if Hit2 and Hit2.Name == "Ignorable" or Hit2.Name == "Glass" or Hit2.Name == "Ignore" or Hit2.Parent.Name == "Top" or Hit2.Parent.Name == "Helmet" or Hit2.Parent.Name == "Up" or Hit2.Parent.Name == "Down" or Hit2.Parent.Name == "Face" or Hit2.Parent.Name == "Olho" or Hit2.Parent.Name == "Headset" or Hit2.Parent.Name == "Numero" or Hit2.Parent.Name == "Vest" or Hit2.Parent.Name == "Chest" or Hit2.Parent.Name == "Waist" or Hit2.Parent.Name == "Back" or Hit2.Parent.Name == "Belt" or Hit2.Parent.Name == "Leg1" or Hit2.Parent.Name == "Leg2" or Hit2.Parent.Name == "Arm1" or Hit2.Parent.Name == "Arm2" then
table.insert(Ignore_Model, Hit2)
return meleeCast()
end
if Hit2 and Hit2.Parent.Name == "Top" or Hit2.Parent.Name == "Helmet" or Hit2.Parent.Name == "Up" or Hit2.Parent.Name == "Down" or Hit2.Parent.Name == "Face" or Hit2.Parent.Name == "Olho" or Hit2.Parent.Name == "Headset" or Hit2.Parent.Name == "Numero" or Hit2.Parent.Name == "Vest" or Hit2.Parent.Name == "Chest" or Hit2.Parent.Name == "Waist" or Hit2.Parent.Name == "Back" or Hit2.Parent.Name == "Belt" or Hit2.Parent.Name == "Leg1" or Hit2.Parent.Name == "Leg2" or Hit2.Parent.Name == "Arm1" or Hit2.Parent.Name == "Arm2" then
table.insert(Ignore_Model, Hit2.Parent)
return meleeCast()
end
if Hit2 and (Hit2.Transparency >= 1 or Hit2.CanCollide == false) and Hit2.Name ~= 'Head' and Hit2.Name ~= 'Right Arm' and Hit2.Name ~= 'Left Arm' and Hit2.Name ~= 'Right Leg' and Hit2.Name ~= 'Left Leg' and Hit2.Name ~= "UpperTorso" and Hit2.Name ~= "LowerTorso" and Hit2.Name ~= "RightUpperArm" and Hit2.Name ~= "RightLowerArm" and Hit2.Name ~= "RightHand" and Hit2.Name ~= "LeftUpperArm" and Hit2.Name ~= "LeftLowerArm" and Hit2.Name ~= "LeftHand" and Hit2.Name ~= "RightUpperLeg" and Hit2.Name ~= "RightLowerLeg" and Hit2.Name ~= "RightFoot" and Hit2.Name ~= "LeftUpperLeg" and Hit2.Name ~= "LeftLowerLeg" and Hit2.Name ~= "LeftFoot" and Hit2.Name ~= 'Armor' and Hit2.Name ~= 'EShield' then
table.insert(Ignore_Model, Hit2)
return meleeCast()
end
end
if raycastResult then
local FoundHuman,VitimaHuman = CheckForHumanoid(raycastResult.Instance)
HitMod.HitEffect(Ignore_Model, raycastResult.Position, raycastResult.Instance , raycastResult.Normal, raycastResult.Material, WeaponData)
Evt.HitEffect:FireServer(raycastResult.Position, raycastResult.Instance , raycastResult.Normal, raycastResult.Material, WeaponData)
local HitPart = raycastResult.Instance
if FoundHuman == true and VitimaHuman.Health > 0 then
local SKP_02 = SKP_01.."-"..plr.UserId
if HitPart.Name == "Head" or HitPart.Parent.Name == "Top" or HitPart.Parent.Name == "Headset" or HitPart.Parent.Name == "Olho" or HitPart.Parent.Name == "Face" or HitPart.Parent.Name == "Numero" then
Thread:Spawn(function()
Evt.Damage:InvokeServer(WeaponTool, VitimaHuman, 0, 1, WeaponData, ModTable, nil, nil, SKP_02)
end)
elseif HitPart.Name == "Torso" or HitPart.Name == "UpperTorso" or HitPart.Name == "LowerTorso" or HitPart.Parent.Name == "Chest" or HitPart.Parent.Name == "Waist" or HitPart.Name == "RightUpperArm" or HitPart.Name == "RightLowerArm" or HitPart.Name == "RightHand" or HitPart.Name == "LeftUpperArm" or HitPart.Name == "LeftLowerArm" or HitPart.Name == "LeftHand" then
Thread:Spawn(function()
Evt.Damage:InvokeServer(WeaponTool, VitimaHuman, 0, 2, WeaponData, ModTable, nil, nil, SKP_02)
end)
elseif HitPart.Name == "Right Arm" or HitPart.Name == "Right Leg" or HitPart.Name == "Left Leg" or HitPart.Name == "Left Arm" or HitPart.Name == "RightUpperLeg" or HitPart.Name == "RightLowerLeg" or HitPart.Name == "RightFoot" or HitPart.Name == "LeftUpperLeg" or HitPart.Name == "LeftLowerLeg" or HitPart.Name == "LeftFoot" then
Thread:Spawn(function()
Evt.Damage:InvokeServer(WeaponTool, VitimaHuman, 0, 3, WeaponData, ModTable, nil, nil, SKP_02)
end)
end
end
end
end
function UpdateGui()
if SE_GUI then
local HUD = SE_GUI.GunHUD
if WeaponData ~= nil then
--[[if Settings.ArcadeMode == true then
HUD.Ammo.Visible = true
HUD.Ammo.AText.Text = Ammo.Value.."|"..Settings.Ammo
else
HUD.Ammo.Visible = false
end]]
--[[if Settings.FireModes.Explosive == true and GLChambered.Value == true then
HUD.E.ImageColor3 = Color3.fromRGB(255,255,255)
HUD.E.Visible = true
elseif Settings.FireModes.Explosive == true and GLChambered.Value == false then
HUD.E.ImageColor3 = Color3.fromRGB(255,0,0)
HUD.E.Visible = true
elseif Settings.FireModes.Explosive == false then
HUD.E.Visible = false
end]]
if WeaponData.Jammed then
HUD.B.BackgroundColor3 = Color3.fromRGB(255,0,0)
else
HUD.B.BackgroundColor3 = Color3.fromRGB(255,255,255)
end
if SafeMode then
HUD.A.Visible = true
else
HUD.A.Visible = false
end
if Ammo > 0 then
HUD.B.Visible = true
else
HUD.B.Visible = false
end
if WeaponData.ShootType == 1 then
HUD.FText.Text = "Semi"
elseif WeaponData.ShootType == 2 then
HUD.FText.Text = "Burst"
elseif WeaponData.ShootType == 3 then
HUD.FText.Text = "Auto"
elseif WeaponData.ShootType == 4 then
HUD.FText.Text = "Pump-Action"
elseif WeaponData.ShootType == 5 then
HUD.FText.Text = "Bolt-Action"
end
HUD.Sens.Text = (Sens/100)
HUD.BText.Text = WeaponData.BulletType
HUD.NText.Text = WeaponData.gunName
if WeaponData.EnableZeroing then
HUD.ZeText.Visible = true
HUD.ZeText.Text = WeaponData.CurrentZero .." m"
else
HUD.ZeText.Visible = false
end
if WeaponData.MagCount then
HUD.SAText.Text = math.ceil(StoredAmmo/WeaponData.Ammo)
HUD.Magazines.Visible = true
HUD.Bullets.Visible = false
else
HUD.SAText.Text = StoredAmmo
HUD.Magazines.Visible = false
HUD.Bullets.Visible = true
end
if Suppressor then
HUD.Att.Silencer.Visible = true
else
HUD.Att.Silencer.Visible = false
end
if LaserAtt then
HUD.Att.Laser.Visible = true
if LaserActive then
if IRmode then
TS:Create(HUD.Att.Laser, TweenInfo.new(.1,Enum.EasingStyle.Linear), {ImageColor3 = Color3.fromRGB(0,255,0), ImageTransparency = .123}):Play()
else
TS:Create(HUD.Att.Laser, TweenInfo.new(.1,Enum.EasingStyle.Linear), {ImageColor3 = Color3.fromRGB(255,255,255), ImageTransparency = .123}):Play()
end
else
TS:Create(HUD.Att.Laser, TweenInfo.new(.1,Enum.EasingStyle.Linear), {ImageColor3 = Color3.fromRGB(255,0,0), ImageTransparency = .5}):Play()
end
else
HUD.Att.Laser.Visible = false
end
if BipodAtt then
HUD.Att.Bipod.Visible = true
else
HUD.Att.Bipod.Visible = false
end
if TorchAtt then
HUD.Att.Flash.Visible = true
if TorchActive then
TS:Create(HUD.Att.Flash, TweenInfo.new(.1,Enum.EasingStyle.Linear), {ImageColor3 = Color3.fromRGB(255,255,255), ImageTransparency = .123}):Play()
else
TS:Create(HUD.Att.Flash, TweenInfo.new(.1,Enum.EasingStyle.Linear), {ImageColor3 = Color3.fromRGB(255,0,0), ImageTransparency = .5}):Play()
end
else
HUD.Att.Flash.Visible = false
end
if WeaponData.Type == "Grenade" then
SE_GUI.GrenadeForce.Visible = true
else
SE_GUI.GrenadeForce.Visible = false
end
end
end
end
function CheckMagFunction()
if aimming then
aimming = false
ADS(aimming)
end
if SE_GUI then
local HUD = SE_GUI.GunHUD
TS:Create(HUD.CMText,TweenInfo.new(.25,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0),{TextTransparency = 0,TextStrokeTransparency = 0.75}):Play()
if Ammo >= WeaponData.Ammo then
HUD.CMText.Text = "Full"
elseif Ammo > math.floor((WeaponData.Ammo)*.75) and Ammo < WeaponData.Ammo then
HUD.CMText.Text = "Nearly full"
elseif Ammo < math.floor((WeaponData.Ammo)*.75) and Ammo > math.floor((WeaponData.Ammo)*.5) then
HUD.CMText.Text = "Almost half"
elseif Ammo == math.floor((WeaponData.Ammo)*.5) then
HUD.CMText.Text = "Half"
elseif Ammo > math.ceil((WeaponData.Ammo)*.25) and Ammo < math.floor((WeaponData.Ammo)*.5) then
HUD.CMText.Text = "Less than half"
elseif Ammo < math.ceil((WeaponData.Ammo)*.25) and Ammo > 0 then
HUD.CMText.Text = "Almost empty"
elseif Ammo == 0 then
HUD.CMText.Text = "Empty"
end
delay(.25,function()
TS:Create(HUD.CMText,TweenInfo.new(.25,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,5),{TextTransparency = 1,TextStrokeTransparency = 1}):Play()
end)
end
mouse1down = false
SafeMode = false
GunStance = 0
Evt.GunStance:FireServer(GunStance,AnimData)
UpdateGui()
MagCheckAnim()
RunCheck()
end
function Grenade()
if not GRDebounce then
GRDebounce = true
GrenadeReady()
repeat
wait()
until not CookGrenade
TossGrenade()
end
end
function TossGrenade()
if WeaponTool and WeaponData and GRDebounce == true then
local SKP_02 = SKP_01.."-"..plr.UserId
GrenadeThrow()
if WeaponTool and WeaponData then
Evt.Grenade:FireServer(WeaponTool,WeaponData,cam.CFrame,cam.CFrame.LookVector,Power,SKP_02)
unset()
end
end
end
function GrenadeMode()
if Power >= 150 then
Power = 100
SE_GUI.GrenadeForce.Text = "Mid Throw"
elseif Power >= 100 then
Power = 50
SE_GUI.GrenadeForce.Text = "Low Throw"
elseif Power >= 50 then
Power = 150
SE_GUI.GrenadeForce.Text = "High Throw"
end
end
function JamChance()
if WeaponData.CanBreak == true and not WeaponData.Jammed and Ammo - 1 > 0 then
local Jam = math.random(1000)
if Jam <= 2 then
WeaponData.Jammed = true
WeaponInHand.Handle.Click:Play()
end
end
end
function Jammed()
if WeaponData.Type == "Gun" and WeaponData.Jammed then
mouse1down = false
reloading = true
SafeMode = false
GunStance = 0
Evt.GunStance:FireServer(GunStance,AnimData)
UpdateGui()
JammedAnim()
WeaponData.Jammed = false
UpdateGui()
reloading = false
RunCheck()
end
end
function Reload()
if WeaponData.Type == "Gun" and StoredAmmo > 0 and (Ammo < WeaponData.Ammo or WeaponData.IncludeChamberedBullet and Ammo < WeaponData.Ammo + 1) then
mouse1down = false
reloading = true
SafeMode = false
GunStance = 0
Evt.GunStance:FireServer(GunStance,AnimData)
UpdateGui()
if WeaponData.ShellInsert then
if Ammo > 0 then
for i = 1,WeaponData.Ammo - Ammo do
if StoredAmmo > 0 and Ammo < WeaponData.Ammo then
if CancelReload then
break
end
ReloadAnim()
Ammo = Ammo + 1
StoredAmmo = StoredAmmo - 1
UpdateGui()
end
end
else
TacticalReloadAnim()
Ammo = Ammo + 1
StoredAmmo = StoredAmmo - 1
UpdateGui()
for i = 1,WeaponData.Ammo - Ammo do
if StoredAmmo > 0 and Ammo < WeaponData.Ammo then
if CancelReload then
break
end
ReloadAnim()
Ammo = Ammo + 1
StoredAmmo = StoredAmmo - 1
UpdateGui()
end
end
end
else
if Ammo > 0 then
ReloadAnim()
else
TacticalReloadAnim()
end
if (Ammo - (WeaponData.Ammo - StoredAmmo)) < 0 then
Ammo = Ammo + StoredAmmo
StoredAmmo = 0
elseif Ammo <= 0 then
StoredAmmo = StoredAmmo - (WeaponData.Ammo - Ammo)
Ammo = WeaponData.Ammo
elseif Ammo > 0 and WeaponData.IncludeChamberedBullet then
StoredAmmo = StoredAmmo - (WeaponData.Ammo - Ammo) - 1
Ammo = WeaponData.Ammo + 1
elseif Ammo > 0 and not WeaponData.IncludeChamberedBullet then
StoredAmmo = StoredAmmo - (WeaponData.Ammo - Ammo)
Ammo = WeaponData.Ammo
end
end
CancelReload = false
reloading = false
RunCheck()
UpdateGui()
end
end
function GunFx()
if Suppressor == true then
WeaponInHand.Handle.Muzzle.Supressor:Play()
else
WeaponInHand.Handle.Muzzle.Fire:Play()
end
if FlashHider == true then
WeaponInHand.Handle.Muzzle["Smoke"]:Emit(10)
else
WeaponInHand.Handle.Muzzle["FlashFX[Flash]"]:Emit(10)
WeaponInHand.Handle.Muzzle["Smoke"]:Emit(10)
end
if BSpread then
BSpread = math.min(WeaponData.MaxSpread * ModTable.MaxSpread, BSpread + WeaponData.AimInaccuracyStepAmount * ModTable.AimInaccuracyStepAmount)
RecoilPower = math.min(WeaponData.MaxRecoilPower * ModTable.MaxRecoilPower, RecoilPower + WeaponData.RecoilPowerStepAmount * ModTable.RecoilPowerStepAmount)
end
generateBullet = generateBullet + 1
LastSpreadUpdate = time()
if Ammo > 0 or not WeaponData.SlideLock then
TS:Create( WeaponInHand.Handle.Slide, TweenInfo.new(30/WeaponData.ShootRate,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,true,0), {C0 = WeaponData.SlideEx:inverse() }):Play()
elseif Ammo <= 0 and WeaponData.SlideLock then
TS:Create( WeaponInHand.Handle.Slide, TweenInfo.new(30/WeaponData.ShootRate,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0), {C0 = WeaponData.SlideEx:inverse() }):Play()
end
WeaponInHand.Handle.Chamber.Smoke:Emit(10)
WeaponInHand.Handle.Chamber.Shell:Emit(1)
end
function Shoot()
if WeaponData and WeaponData.Type == "Gun" and not shooting and not reloading then
if reloading or runKeyDown or SafeMode or CheckingMag then
mouse1down = false
return
end
if Ammo <= 0 or WeaponData.Jammed then
WeaponInHand.Handle.Click:Play()
mouse1down = false
return
end
mouse1down = true
delay(0, function()
if WeaponData and WeaponData.ShootType == 1 then
shooting = true
Evt.Atirar:FireServer(WeaponTool,Suppressor,FlashHider)
for _ = 1, WeaponData.Bullets do
Thread:Spawn(CreateBullet)
end
Ammo = Ammo - 1
GunFx()
JamChance()
UpdateGui()
Thread:Spawn(Recoil)
wait(60/WeaponData.ShootRate)
shooting = false
elseif WeaponData and WeaponData.ShootType == 2 then
for i = 1, WeaponData.BurstShot do
if shooting or Ammo <= 0 or mouse1down == false or WeaponData.Jammed then
break
end
shooting = true
Evt.Atirar:FireServer(WeaponTool,Suppressor,FlashHider)
for _ = 1, WeaponData.Bullets do
Thread:Spawn(CreateBullet)
end
Ammo = Ammo - 1
GunFx()
JamChance()
UpdateGui()
Thread:Spawn(Recoil)
wait(60/WeaponData.ShootRate)
shooting = false
end
elseif WeaponData and WeaponData.ShootType == 3 then
while mouse1down do
if shooting or Ammo <= 0 or WeaponData.Jammed then
break
end
shooting = true
Evt.Atirar:FireServer(WeaponTool,Suppressor,FlashHider)
for _ = 1, WeaponData.Bullets do
Thread:Spawn(CreateBullet)
end
Ammo = Ammo - 1
GunFx()
JamChance()
UpdateGui()
Thread:Spawn(Recoil)
wait(60/WeaponData.ShootRate)
shooting = false
end
elseif WeaponData and WeaponData.ShootType == 4 or WeaponData and WeaponData.ShootType == 5 then
shooting = true
Evt.Atirar:FireServer(WeaponTool,Suppressor,FlashHider)
for _ = 1, WeaponData.Bullets do
Thread:Spawn(CreateBullet)
end
Ammo = Ammo - 1
GunFx()
UpdateGui()
Thread:Spawn(Recoil)
PumpAnim()
RunCheck()
shooting = false
end
end)
elseif WeaponData and WeaponData.Type == "Melee" and not runKeyDown then
if not shooting then
shooting = true
meleeCast()
meleeAttack()
RunCheck()
shooting = false
end
end
end
local L_150_ = {}
local LeanSpring = {}
LeanSpring.cornerPeek = SpringMod.new(0)
LeanSpring.cornerPeek.d = 1
LeanSpring.cornerPeek.s = 20
LeanSpring.peekFactor = math.rad(-15)
LeanSpring.dirPeek = 0
function L_150_.Update()
LeanSpring.cornerPeek.t = LeanSpring.peekFactor * Virar
local NewLeanCF = CFrame.fromAxisAngle(Vector3.new(0, 0, 1), LeanSpring.cornerPeek.p)
cam.CFrame = cam.CFrame * NewLeanCF
end
game:GetService("RunService"):BindToRenderStep("Camera Update", 200, L_150_.Update)
function RunCheck()
if runKeyDown then
mouse1down = false
GunStance = 3
Evt.GunStance:FireServer(GunStance,AnimData)
SprintAnim()
else
if aimming then
GunStance = 2
Evt.GunStance:FireServer(GunStance,AnimData)
else
GunStance = 0
Evt.GunStance:FireServer(GunStance,AnimData)
end
IdleAnim()
end
end
function Stand()
Stance:FireServer(Stances,Virar)
TS:Create(char.Humanoid, TweenInfo.new(.3), {CameraOffset = Vector3.new(CameraX,CameraY,0)} ):Play()
SE_GUI.MainFrame.Poses.Levantado.Visible = true
SE_GUI.MainFrame.Poses.Agaixado.Visible = false
SE_GUI.MainFrame.Poses.Deitado.Visible = false
if Steady then
char.Humanoid.WalkSpeed = gameRules.SlowPaceWalkSpeed
char.Humanoid.JumpPower = gameRules.JumpPower
else
if script.Parent:GetAttribute("Injured") then
char.Humanoid.WalkSpeed = gameRules.InjuredWalksSpeed
char.Humanoid.JumpPower = gameRules.JumpPower
else
char.Humanoid.WalkSpeed = gameRules.NormalWalkSpeed
char.Humanoid.JumpPower = gameRules.JumpPower
end
end
IsStanced = false
end
function Crouch()
Stance:FireServer(Stances,Virar)
TS:Create(char.Humanoid, TweenInfo.new(.3), {CameraOffset = Vector3.new(CameraX,CameraY,0)} ):Play()
SE_GUI.MainFrame.Poses.Levantado.Visible = false
SE_GUI.MainFrame.Poses.Agaixado.Visible = true
SE_GUI.MainFrame.Poses.Deitado.Visible = false
if script.Parent:GetAttribute("Injured") then
char.Humanoid.WalkSpeed = gameRules.InjuredCrouchWalkSpeed
char.Humanoid.JumpPower = 0
else
char.Humanoid.WalkSpeed = gameRules.CrouchWalkSpeed
char.Humanoid.JumpPower = 0
end
IsStanced = true
end
function Prone()
Stance:FireServer(Stances,Virar)
TS:Create(char.Humanoid, TweenInfo.new(.3), {CameraOffset = Vector3.new(CameraX,CameraY,0)} ):Play()
SE_GUI.MainFrame.Poses.Levantado.Visible = false
SE_GUI.MainFrame.Poses.Agaixado.Visible = false
SE_GUI.MainFrame.Poses.Deitado.Visible = true
if ACS_Client:GetAttribute("Surrender") then
char.Humanoid.WalkSpeed = 0
else
char.Humanoid.WalkSpeed = gameRules.ProneWalksSpeed
end
char.Humanoid.JumpPower = 0
IsStanced = true
end
function Lean()
TS:Create(char.Humanoid, TweenInfo.new(.3), {CameraOffset = Vector3.new(CameraX,CameraY,0)} ):Play()
Stance:FireServer(Stances,Virar)
if Virar == 0 then
SE_GUI.MainFrame.Poses.Esg_Left.Visible = false
SE_GUI.MainFrame.Poses.Esg_Right.Visible = false
elseif Virar == 1 then
SE_GUI.MainFrame.Poses.Esg_Left.Visible = false
SE_GUI.MainFrame.Poses.Esg_Right.Visible = true
elseif Virar == -1 then
SE_GUI.MainFrame.Poses.Esg_Left.Visible = true
SE_GUI.MainFrame.Poses.Esg_Right.Visible = false
end
end
|
--[[Steering]] |
Tune.SteerInner = 36 -- Inner wheel steering angle (in degrees)
Tune.SteerOuter = 37 -- Outer wheel steering angle (in degrees)
Tune.SteerSpeed = .05 -- Steering increment per tick (in degrees)
Tune.ReturnSpeed = .1 -- Steering increment per tick (in degrees)
Tune.SteerDecay = 320 -- Speed of gradient cutoff (in SPS)
Tune.MinSteer = 10 -- Minimum steering at max steer decay (in percent)
Tune.MSteerExp = 1 -- Mouse steering exponential degree
--Steer Gyro Tuning
Tune.SteerD = 1000 -- Steering Dampening
Tune.SteerMaxTorque = 50000 -- Steering Force
Tune.SteerP = 100000 -- Steering Aggressiveness
|
--script.Parent.HH.Velocity = script.Parent.HH.CFrame.lookVector *script.Parent.Speed.Value
--script.Parent.HHH.Velocity = script.Parent.HHH.CFrame.lookVector *script.Parent.Speed.Value |
script.Parent.HHHH.Velocity = script.Parent.HHHH.CFrame.lookVector *script.Parent.Speed.Value
script.Parent.I.Velocity = script.Parent.I.CFrame.lookVector *script.Parent.Speed.Value |
--////////////////////////////// Methods
--////////////////////////////////////// |
local methods = {}
methods.__index = methods
local function CreateGuiObjects()
local BaseFrame = Instance.new("Frame")
BaseFrame.Selectable = false
BaseFrame.Size = UDim2.new(1, 0, 1, 0)
BaseFrame.BackgroundTransparency = 1
local Scroller = Instance.new("ScrollingFrame")
Scroller.Selectable = ChatSettings.GamepadNavigationEnabled
Scroller.Name = "Scroller"
Scroller.BackgroundTransparency = 1
Scroller.BorderSizePixel = 0
Scroller.Position = UDim2.new(0, 0, 0, 3)
Scroller.Size = UDim2.new(1, -4, 1, -6)
Scroller.CanvasSize = UDim2.new(0, 0, 0, 0)
Scroller.ScrollBarThickness = module.ScrollBarThickness
Scroller.Active = true
Scroller.Parent = BaseFrame
local Layout = Instance.new("UIListLayout")
Layout.SortOrder = Enum.SortOrder.LayoutOrder
Layout.Parent = Scroller
return BaseFrame, Scroller, Layout
end
function methods:Destroy()
self.GuiObject:Destroy()
self.Destroyed = true
end
function methods:SetActive(active)
self.GuiObject.Visible = active
end
function methods:UpdateMessageFiltered(messageData)
local messageObject = nil
local searchIndex = 1
local searchTable = self.MessageObjectLog
while (#searchTable >= searchIndex) do
local obj = searchTable[searchIndex]
if obj.ID == messageData.ID then
messageObject = obj
break
end
searchIndex = searchIndex + 1
end
if messageObject then
if UserFlagRemoveMessageOnTextFilterFailures then
if messageData.Message == "" then
self:RemoveMessageAtIndex(searchIndex)
else
messageObject.UpdateTextFunction(messageData)
self:PositionMessageLabelInWindow(messageObject, searchIndex)
end
else
messageObject.UpdateTextFunction(messageData)
self:PositionMessageLabelInWindow(messageObject, searchIndex)
end
end
end
function methods:AddMessage(messageData)
self:WaitUntilParentedCorrectly()
local messageObject = MessageLabelCreator:CreateMessageLabel(messageData, self.CurrentChannelName)
if messageObject == nil then
return
end
table.insert(self.MessageObjectLog, messageObject)
self:PositionMessageLabelInWindow(messageObject, #self.MessageObjectLog)
end
function methods:RemoveMessageAtIndex(index)
self:WaitUntilParentedCorrectly()
local removeThis = self.MessageObjectLog[index]
if removeThis then
removeThis:Destroy()
table.remove(self.MessageObjectLog, index)
end
end
function methods:AddMessageAtIndex(messageData, index)
local messageObject = MessageLabelCreator:CreateMessageLabel(messageData, self.CurrentChannelName)
if messageObject == nil then
return
end
table.insert(self.MessageObjectLog, index, messageObject)
self:PositionMessageLabelInWindow(messageObject, index)
end
function methods:RemoveLastMessage()
self:WaitUntilParentedCorrectly()
local lastMessage = self.MessageObjectLog[1]
lastMessage:Destroy()
table.remove(self.MessageObjectLog, 1)
end
function methods:IsScrolledDown()
local yCanvasSize = self.Scroller.CanvasSize.Y.Offset
local yContainerSize = self.Scroller.AbsoluteWindowSize.Y
local yScrolledPosition = self.Scroller.CanvasPosition.Y
return (yCanvasSize < yContainerSize or
yCanvasSize - yScrolledPosition <= yContainerSize + 5)
end
function methods:UpdateMessageTextHeight(messageObject)
local baseFrame = messageObject.BaseFrame
for i = 1, 10 do
if messageObject.BaseMessage.TextFits then
break
end
local trySize = self.Scroller.AbsoluteSize.X - i
baseFrame.Size = UDim2.new(1, 0, 0, messageObject.GetHeightFunction(trySize))
end
end
function methods:PositionMessageLabelInWindow(messageObject, index)
self:WaitUntilParentedCorrectly()
local wasScrolledDown = self:IsScrolledDown()
local baseFrame = messageObject.BaseFrame
local layoutOrder = 1
if self.MessageObjectLog[index - 1] then
if index == #self.MessageObjectLog then
layoutOrder = self.MessageObjectLog[index - 1].BaseFrame.LayoutOrder + 1
else
layoutOrder = self.MessageObjectLog[index - 1].BaseFrame.LayoutOrder
end
end
baseFrame.LayoutOrder = layoutOrder
baseFrame.Size = UDim2.new(1, 0, 0, messageObject.GetHeightFunction(self.Scroller.AbsoluteSize.X))
baseFrame.Parent = self.Scroller
if messageObject.BaseMessage then
self:UpdateMessageTextHeight(messageObject)
end
if wasScrolledDown then
self.Scroller.CanvasPosition = Vector2.new(
0, math.max(0, self.Scroller.CanvasSize.Y.Offset - self.Scroller.AbsoluteSize.Y))
end
end
function methods:ReorderAllMessages()
self:WaitUntilParentedCorrectly()
--// Reordering / reparenting with a size less than 1 causes weird glitches to happen
-- with scrolling as repositioning happens.
if self.GuiObject.AbsoluteSize.Y < 1 then return end
local oldCanvasPositon = self.Scroller.CanvasPosition
local wasScrolledDown = self:IsScrolledDown()
for _, messageObject in pairs(self.MessageObjectLog) do
self:UpdateMessageTextHeight(messageObject)
end
if not wasScrolledDown then
self.Scroller.CanvasPosition = oldCanvasPositon
else
self.Scroller.CanvasPosition = Vector2.new(
0, math.max(0, self.Scroller.CanvasSize.Y.Offset - self.Scroller.AbsoluteSize.Y))
end
end
function methods:Clear()
for _, v in pairs(self.MessageObjectLog) do
v:Destroy()
end
self.MessageObjectLog = {}
end
function methods:SetCurrentChannelName(name)
self.CurrentChannelName = name
end
function methods:FadeOutBackground(duration)
--// Do nothing
end
function methods:FadeInBackground(duration)
--// Do nothing
end
function methods:FadeOutText(duration)
for i = 1, #self.MessageObjectLog do
if self.MessageObjectLog[i].FadeOutFunction then
self.MessageObjectLog[i].FadeOutFunction(duration, CurveUtil)
end
end
end
function methods:FadeInText(duration)
for i = 1, #self.MessageObjectLog do
if self.MessageObjectLog[i].FadeInFunction then
self.MessageObjectLog[i].FadeInFunction(duration, CurveUtil)
end
end
end
function methods:Update(dtScale)
for i = 1, #self.MessageObjectLog do
if self.MessageObjectLog[i].UpdateAnimFunction then
self.MessageObjectLog[i].UpdateAnimFunction(dtScale, CurveUtil)
end
end
end
|
-- Base script for NPC enemy movement,
-- still a work in progress | |
-- -- -- -- -- -- --
--DIRECTION SCROLL--
-- -- -- -- -- -- -- |
Elevator:WaitForChild("Direction").Changed:connect(function(val)
if val == 1 then
This.Display.ARW1.U.Color = DisplayColor
This.Display.ARW1.M.Color = DisplayColor
This.Display.ARW1.D.Color = DisabledColor
This.Display.ARW1.U.Material = Lit
This.Display.ARW1.M.Material = Lit
This.Display.ARW1.D.Material = Unlit
elseif val == -1 then
This.Display.ARW1.U.Color = DisabledColor
This.Display.ARW1.M.Color = DisplayColor
This.Display.ARW1.D.Color = DisplayColor
This.Display.ARW1.U.Material = Unlit
This.Display.ARW1.M.Material = Lit
This.Display.ARW1.D.Material = Lit
else
This.Display.ARW1.U.Color = DisabledColor
This.Display.ARW1.M.Color = DisabledColor
This.Display.ARW1.D.Color = DisabledColor
This.Display.ARW1.U.Material = Unlit
This.Display.ARW1.M.Material = Unlit
This.Display.ARW1.D.Material = Unlit
end
end)
|
-- CONSTRUCTOR |
function Signal.new(trackConnectionsChanged)
local self = setmetatable({}, Signal)
self._bindableEvent = Instance.new("BindableEvent")
if trackConnectionsChanged then
self.connectionsChanged = Signal.new()
end
return self
end
|
--[[ Gamepad Support ]] | --
local THUMBSTICK_DEADZONE = 0.2
local r3ButtonDown = false
local l3ButtonDown = false
local currentZoomSpeed = 1 -- Multiplier, so 1 == no zooming
local function clamp(value, minValue, maxValue)
if maxValue < minValue then
maxValue = minValue
end
return math.clamp(value, minValue, maxValue)
end
local function IsFinite(num)
return num == num and num ~= 1/0 and num ~= -1/0
end
local function IsFiniteVector3(vec3)
return IsFinite(vec3.x) and IsFinite(vec3.y) and IsFinite(vec3.z)
end
|
--[[killEvent.OnClientEvent:connect(function()
KillText.TextTransparency = 0
delay(2, function()
local testTween = tweenService:Create(KillText,killInfo,killGoals)
testTween:Play()
end)
end)]] | --
|
--[[Drivetrain]] |
Tune.Config = "FWD" --"FWD" , "RWD" , "AWD"
--Differential Settings
Tune.FDiffSlipThres = 50 -- 1 - 100% (Max threshold of applying full lock determined by deviation from avg speed)
Tune.FDiffLockThres = 50 -- 0 - 100% (0 - Bias toward slower wheel, 100 - Bias toward faster wheel)
Tune.RDiffSlipThres = 50 -- 1 - 100%
Tune.RDiffLockThres = 50 -- 0 - 100%
Tune.CDiffSlipThres = 50 -- 1 - 100% [AWD Only]
Tune.CDiffLockThres = 50 -- 0 - 100% [AWD Only]
--Traction Control Settings
Tune.TCSEnabled = true -- Implements TCS
Tune.TCSThreshold = 20 -- Slip speed allowed before TCS starts working (in SPS)
Tune.TCSGradient = 20 -- Slip speed gradient between 0 to max reduction (in SPS)
Tune.TCSLimit = 10 -- Minimum amount of torque at max reduction (in percent)
|
----------------------------------------------------------------------------------------------------
--------------------=[ OUTROS ]=--------------------------------------------------------------------
---------------------------------------------------------------------------------------------------- |
,FastReload = true --- Automatically operates the bolt on reload if needed
,SlideLock = true
,MoveBolt = false
,BoltLock = false
,CanBreachDoor = true
,CanBreak = true --- Weapon can jam?
,JamChance = 1000 --- This old piece of brick doesn't work fine >;c
,IncludeChamberedBullet = true --- Include the chambered bullet on next reload
,Chambered = false --- Start with the gun chambered?
,LauncherReady = false --- Start with the GL ready?
,CanCheckMag = true --- You can check the magazine
,ArcadeMode = false --- You can see the bullets left in magazine
,RainbowMode = false --- Operation: Party Time xD
,ModoTreino = false --- Surrender enemies instead of killing them
,GunSize = 1.25
,GunFOVReduction = 5
,BoltExtend = Vector3.new(0, 0, 0.225)
,SlideExtend = Vector3.new(0, 0, 0.225) |
--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)
|
--[[**
ensures all values in given table pass check
@param check The function to use to check the values
@returns A function that will return true iff the condition is passed
**--]] |
function t.values(check)
assert(t.callback(check))
return function(value)
local tableSuccess, tableErrMsg = t.table(value)
if tableSuccess == false then
return false, tableErrMsg or ""
end
for key, val in pairs(value) do
local success, errMsg = check(val)
if success == false then
return false, string.format("bad value for key %s:\n\t%s", tostring(key), errMsg or "")
end
end
return true
end
end
|
-- ROBLOX deviation: matcher does not have RawMatcherFn type annotation and the
-- the function return is not annotated with ThrowingMatcherFn |
function makeThrowingMatcher(
matcher: RawMatcherFn,
isNot: boolean,
promise: string,
actual: any,
err: JestAssertionError?
): ThrowingMatcherFn
return function(...)
local throws = true
local utils = Object.assign({
iterableEquality = iterableEquality,
subsetEquality = subsetEquality,
-- ROBLOX deviation: Roblox Instance matchers
-- instanceSubsetEquality = instanceSubsetEquality
}, matcherUtils)
local matcherContext = {
-- When throws is disabled, the matcher will not throw errors during test
-- execution but instead add them to the global matcher state. If a
-- matcher throws, test execution is normally stopped immediately. The
-- snapshot matcher uses it because we want to log all snapshot
-- failures in a test.
dontThrow = function()
throws = false
end,
equals = equals,
error = err,
isNot = isNot,
promise = promise,
utils = utils,
}
Object.assign(matcherContext, getState())
local function processResult(result: SyncExpectationResult, asyncError: JestAssertionError?)
_validateResult(result)
getState().assertionCalls = getState().assertionCalls + 1
if (result.pass and isNot) or (not result.pass and not isNot) then
-- XOR
local message = getMessage(result.message)
local error_
if err then
error_ = err
error_.message = message
elseif asyncError then
error("Currently async is not implemented")
else
error_ = {}
error_.message = message
end
-- Passing the result of the matcher with the error so that a custom
-- reporter could access the actual and expected objects of the result
-- for example in order to display a custom visual diff
error_.matcherResult = Object.assign({}, result, { message = message })
if throws then
error(AssertionError.new({ message = message }))
else
table.insert(getState().suppressedErrors, error)
end
end
end
local potentialResult, preservedStack, result
local ok = xpcall(function(...)
-- ROBLOX TODO: Implement INTERNAL_MATCHER_FLAG cases
potentialResult = matcher(matcherContext, actual, ...)
local syncResult = potentialResult
return processResult(syncResult)
end, function(e)
preservedStack = debug.traceback(nil, 7)
result = e
end, ...)
if not ok then
if typeof(result) == "table" and typeof(result.message) == "string" then
local errorTable = AssertionError.new({ message = result.message })
errorTable.stack = preservedStack
error(errorTable)
else
local errorTable = AssertionError.new({ message = result })
errorTable.stack = preservedStack
error(errorTable)
end
end
end
end
function _validateResult(result: any)
if
typeof(result) ~= "table"
or typeof(result.pass) ~= "boolean"
or (result.message and typeof(result.message) ~= "string" and typeof(result.message) ~= "function")
then
error(
"Unexpected return from a matcher function.\n"
.. "Matcher functions should "
.. "return an object in the following format:\n"
.. " {message?: string | function, pass: boolean}\n"
.. matcherUtils.stringify(result)
.. " was returned"
)
end
end
local Expect = {}
|
-- t: a runtime typechecker for Roblox |
local t = {}
function t.type(typeName)
return function(value)
local valueType = type(value)
if valueType == typeName then
return true
else
return false
end
end
end
function t.typeof(typeName)
return function(value)
local valueType = typeof(value)
if valueType == typeName then
return true
else
return false
end
end
end
|
--[[
Main RenderStep Update. The camera controller and occlusion module both have opportunities
to set and modify (respectively) the CFrame and Focus before it is set once on CurrentCamera.
The camera and occlusion modules should only return CFrames, not set the CFrame property of
CurrentCamera directly.
--]] |
function CameraModule:Update(dt)
if self.activeCameraController then
self.activeCameraController:UpdateMouseBehavior()
local newCameraCFrame, newCameraFocus = self.activeCameraController:Update(dt)
if not FFlagUserFlagEnableNewVRSystem then
self.activeCameraController:ApplyVRTransform()
end
if self.activeOcclusionModule then
newCameraCFrame, newCameraFocus = self.activeOcclusionModule:Update(dt, newCameraCFrame, newCameraFocus)
end
-- Here is where the new CFrame and Focus are set for this render frame
game.Workspace.CurrentCamera.CFrame = newCameraCFrame
game.Workspace.CurrentCamera.Focus = newCameraFocus
-- Update to character local transparency as needed based on camera-to-subject distance
if self.activeTransparencyController then
self.activeTransparencyController:Update()
end
if CameraInput.getInputEnabled() then
CameraInput.resetInputForFrameEnd()
end
end
end
|
--[=[
Like [GetRemoteEvent] but in promise form.
@function PromiseGetRemoteEvent
@within PromiseGetRemoteEvent
@param name string
@return Promise<RemoteEvent>
]=] |
if not RunService:IsRunning() then
-- Handle testing
return function(name)
return Promise.resolved(GetRemoteEvent(name))
end
elseif RunService:IsServer() then
return function(name)
return Promise.resolved(GetRemoteEvent(name))
end
else -- RunService:IsClient()
return function(name)
assert(type(name) == "string", "Bad name")
local storage = ReplicatedStorage:FindFirstChild(ResourceConstants.REMOTE_EVENT_STORAGE_NAME)
if storage then
local obj = storage:FindFirstChild(name)
if obj then
return Promise.resolved(obj)
end
end
return Promise.spawn(function(resolve, _)
resolve(GetRemoteEvent(name))
end)
end
end
|
--Misc |
Tune.RevAccel = 150 -- RPM acceleration when clutch is off
Tune.RevDecay = 75 -- RPM decay when clutch is off
Tune.RevBounce = 500 -- RPM kickback from redline
Tune.IdleThrottle = 3 -- Percent throttle at idle
Tune.ClutchTol = 500 -- Clutch engagement threshold (higher = faster response)
|
-- Requires |
local Database = require(ReplicatedStorage.Common.Database)
local APIEquipment = require(ReplicatedStorage.Common.APIEquipment)
|
--[[
Remove the range from the list starting from the index.
]] |
local function removeRange(list, startIndex, endIndex)
assert(startIndex <= endIndex, "startIndex must be less than or equal to endIndex")
local new = {}
local index = 1
for i = 1, math.min(#list, startIndex - 1) do
new[index] = list[i]
index = index + 1
end
for i = endIndex + 1, #list do
new[index] = list[i]
index = index + 1
end
return new
end
return removeRange
|
--------------------------------------------------- |
This = script.Parent
Elevator = This.Parent.Parent.Parent.Parent.Parent
Characters = require(script.Characters)
CustomLabel = require(Elevator.CustomLabel)
CustomText = CustomLabel["CUSTOMFLOORLABEL"]
This.Parent.Parent.Parent.Parent.Parent:WaitForChild("Floor").Changed:connect(function(floor)
--custom indicator code--
ChangeFloor(tostring(floor))
end)
function ChangeFloor(SF)
if CustomText[tonumber(SF)] then
SF = CustomText[tonumber(SF)]
end
SetDisplay(2,(string.len(SF) == 2 and SF:sub(1,1) or "NIL"))
SetDisplay(3,(string.len(SF) == 2 and SF:sub(2,2) or SF))
end
function SetDisplay(ID,CHAR)
if This.Display:FindFirstChild("Matrix"..ID) and Characters[CHAR] ~= nil then
for i,l in pairs(Characters[CHAR]) do
for r=1,5 do
This.Display["Matrix"..ID]["Row"..i]["D"..r].Visible = (l:sub(r,r) == "1" and true or false)
end
end
end
end
for M = 1, Displays do
for R = 1, 7 do
for D = 1, 5 do
This.Display["Matrix"..M]["Row"..R]["D"..D].BackgroundColor3 = DisplayColor
end
end
end
|
--// Recoil Settings |
gunrecoil = -0.5; -- How much the gun recoils backwards when not aiming
camrecoil = 0.5; -- How much the camera flicks when not aiming
AimGunRecoil = -0.5; -- How much the gun recoils backwards when aiming
AimCamRecoil = 0.13; -- How much the camera flicks when aiming
CamShake = 0.5; -- THIS IS NEW!!!! CONTROLS CAMERA SHAKE WHEN FIRING
AimCamShake = 0.5; -- THIS IS ALSO NEW!!!!
Kickback = 1; -- Upward gun rotation when not aiming
AimKickback = 0.5; -- Upward gun rotation when aiming
|
--local |
function module.locaL(part,cf)
local thing = part
thing.CFrame = cf
thing.Parent = game.Workspace.World.Visuals
return thing
end
module.weld = function(data)
local part = data.part
local base = data.basepart
local tim = data.tim or nil
local name = data.name or "Weld"
part.Anchored = false
--base.Anchored = false
local Weld = Instance.new("Weld")
Weld.Name = name
Weld.Part0 = base
Weld.C0 = base.CFrame:inverse()
Weld.Part1 = part
Weld.C1 = part.CFrame:inverse()
Weld.Parent = part
if tim then
game.Debris:AddItem(Weld, tim)
end
end
|
-- Camera math utility library |
local CameraUtils = require(script:WaitForChild("CameraUtils"))
|
-------------------------------------------------------
-- изменение размера контескта под рамку |
local context = me.frmContext
context.Size = UDim2.new(0,me.AbsoluteSize.X-29,0,me.AbsoluteSize.Y-29)
|
-- Function to update the loading time |
local function UpdateLoadingTime(remainingTime)
loadingBar.Text = tostring(remainingTime) .. "s"
end
|
-- main program |
local runService = game:service("RunService");
|
-- functions |
function stopAllAnimations()
local oldAnim = currentAnim
-- return to idle if finishing an emote
if (emoteNames[oldAnim] ~= nil and emoteNames[oldAnim] == false) then
oldAnim = "idle"
end
currentAnim = ""
currentAnimInstance = nil
if (currentAnimKeyframeHandler ~= nil) then
currentAnimKeyframeHandler:disconnect()
end
if (currentAnimTrack ~= nil) then
currentAnimTrack:Stop()
currentAnimTrack:Destroy()
currentAnimTrack = nil
end
return oldAnim
end
function setAnimationSpeed(speed)
if speed ~= currentAnimSpeed then
currentAnimSpeed = speed
currentAnimTrack:AdjustSpeed(currentAnimSpeed)
end
end
function keyFrameReachedFunc(frameName)
if (frameName == "End") then
local repeatAnim = currentAnim
-- return to idle if finishing an emote
if (emoteNames[repeatAnim] ~= nil and emoteNames[repeatAnim] == false) then
repeatAnim = "idle"
end
local animSpeed = currentAnimSpeed
playAnimation(repeatAnim, 0.0, Humanoid)
setAnimationSpeed(animSpeed)
end
end
|
--Precalculated paths |
local t,f,n=true,false,{}
local r={
[58]={{72,71,61,59,41,30,56,58},t},
[49]={{72,71,61,59,41,39,35,34,32,31,29,28,44,45,49},t},
[16]={n,f},
[19]={{72,71,61,59,41,30,56,58,20,19},t},
[59]={{72,71,61,59},t},
[63]={{72,71,61,59,41,30,56,58,23,62,63},t},
[34]={{72,71,61,59,41,39,35,34},t},
[21]={{72,71,61,59,41,30,56,58,20,21},t},
[48]={{72,71,61,59,41,39,35,34,32,31,29,28,44,45,49,48},t},
[27]={{72,71,61,59,41,39,35,34,32,31,29,28,27},t},
[14]={n,f},
[31]={{72,71,61,59,41,39,35,34,32,31},t},
[56]={{72,71,61,59,41,30,56},t},
[29]={{72,71,61,59,41,39,35,34,32,31,29},t},
[13]={n,f},
[47]={{72,71,61,59,41,39,35,34,32,31,29,28,44,45,49,48,47},t},
[12]={n,f},
[45]={{72,71,61,59,41,39,35,34,32,31,29,28,44,45},t},
[57]={{72,71,61,59,41,30,56,57},t},
[36]={{72,71,61,59,41,39,35,37,36},t},
[25]={{72,71,61,59,41,39,35,34,32,31,29,28,27,26,25},t},
[71]={{72,71},t},
[20]={{72,71,61,59,41,30,56,58,20},t},
[60]={{72,71,61,60},t},
[8]={n,f},
[4]={n,f},
[75]={{72,76,73,75},t},
[22]={{72,71,61,59,41,30,56,58,20,21,22},t},
[74]={{72,76,73,74},t},
[62]={{72,71,61,59,41,30,56,58,23,62},t},
[1]={n,f},
[6]={n,f},
[11]={n,f},
[15]={n,f},
[37]={{72,71,61,59,41,39,35,37},t},
[2]={n,f},
[35]={{72,71,61,59,41,39,35},t},
[53]={{72,71,61,59,41,39,35,34,32,31,29,28,44,45,49,48,47,52,53},t},
[73]={{72,76,73},t},
[72]={{72},t},
[33]={{72,71,61,59,41,39,35,37,36,33},t},
[69]={{72,71,61,69},t},
[65]={{72,71,61,59,41,30,56,58,20,19,66,64,65},t},
[26]={{72,71,61,59,41,39,35,34,32,31,29,28,27,26},t},
[68]={{72,71,61,59,41,30,56,58,20,19,66,64,67,68},t},
[76]={{72,76},t},
[50]={{72,71,61,59,41,39,35,34,32,31,29,28,44,45,49,48,47,50},t},
[66]={{72,71,61,59,41,30,56,58,20,19,66},t},
[10]={n,f},
[24]={{72,71,61,59,41,39,35,34,32,31,29,28,27,26,25,24},t},
[23]={{72,71,61,59,41,30,56,58,23},t},
[44]={{72,71,61,59,41,39,35,34,32,31,29,28,44},t},
[39]={{72,71,61,59,41,39},t},
[32]={{72,71,61,59,41,39,35,34,32},t},
[3]={n,f},
[30]={{72,71,61,59,41,30},t},
[51]={{72,71,61,59,41,39,35,34,32,31,29,28,44,45,49,48,47,50,51},t},
[18]={n,f},
[67]={{72,71,61,59,41,30,56,58,20,19,66,64,67},t},
[61]={{72,71,61},t},
[55]={{72,71,61,59,41,39,35,34,32,31,29,28,44,45,49,48,47,52,53,54,55},t},
[46]={{72,71,61,59,41,39,35,34,32,31,29,28,44,45,49,48,47,46},t},
[42]={{72,71,61,59,41,39,40,38,42},t},
[40]={{72,71,61,59,41,39,40},t},
[52]={{72,71,61,59,41,39,35,34,32,31,29,28,44,45,49,48,47,52},t},
[54]={{72,71,61,59,41,39,35,34,32,31,29,28,44,45,49,48,47,52,53,54},t},
[43]={n,f},
[7]={n,f},
[9]={n,f},
[41]={{72,71,61,59,41},t},
[17]={n,f},
[38]={{72,71,61,59,41,39,40,38},t},
[28]={{72,71,61,59,41,39,35,34,32,31,29,28},t},
[5]={n,f},
[64]={{72,71,61,59,41,30,56,58,20,19,66,64},t},
}
return r
|
--cam.FieldOfView=math.random(68,72) |
task.wait()
end
|
-- map a value from one range to another |
function CameraUtils.map(x, inMin, inMax, outMin, outMax)
return (x - inMin)*(outMax - outMin)/(inMax - inMin) + outMin
end
|
--[[**
ensures Roblox RaycastResult type
@param value The value to check against
@returns True iff the condition is satisfied, false otherwise
**--]] |
t.RaycastResult = t.typeof("RaycastResult")
|
-- message recieved, delete StringValue |
animStringValueObject.Parent = nil
toolAnimTime = time + .3
end
if time > toolAnimTime then
toolAnimTime = 0
toolAnim = "None"
end
animateTool()
else
stopToolAnimations()
toolAnim = "None"
toolAnimInstance = nil
toolAnimTime = 0
end
end |
--//Controller//-- |
Trigger.MouseClick:Connect(function(Player)
if not Settings.OnCD then
local Backpack = Player.Backpack
local StarterGear = Player.StarterGear
for _, Tool in pairs(Backpack:GetChildren()) do
if Tool then
Tool:Destroy()
end
end
for _, Tool in pairs(StarterGear:GetChildren()) do
if Tool then
Tool:Destroy()
end
end
local Tool = Tools:FindFirstChild(Gun.Name):Clone()
Tool:Clone().Parent = Backpack
Tool:Clone().Parent = StarterGear
end
end)
|
--[[Transmission]] |
Tune.TransModes = {"Semi"} --"Auto", "Semi", or "Manual". Can have more than one; order from first to last
--Automatic Settings
Tune.AutoShiftMode = "Speed" --"Speed" or "RPM"
Tune.AutoUpThresh = -200 --Automatic upshift point (relative to peak RPM, positive = Over-rev)
Tune.AutoDownThresh = 2000 --Automatic downshift point (relative to peak RPM, positive = Under-rev)
--Gear Ratios
Tune.FinalDrive = 3.84
-- Gearing determines top speed and wheel torque
Tune.Ratios = { -- Higher ratio = more torque, Lower ratio = higher top speed
--[[Reverse]] 3.42 , -- Copy and paste a ratio to add a gear
--[[Neutral]] 0 , -- Ratios can also be deleted
--[[ 1 ]] 4.37 , -- Reverse, Neutral, and 1st gear are required
--[[ 2 ]] 2.76 ,
--[[ 3 ]] 1.94 ,
--[[ 4 ]] 1.45 ,
--[[ 5 ]] 1.05 ,
--[[ 6 ]] .85 ,
--[[ 7 ]] .69 ,
}
Tune.FDMult = 1 -- Ratio multiplier (Change this value instead of FinalDrive if car is struggling with torque ; Default = 1)
|
--[=[
Constructs a new Maid object
```lua
local maid = Maid.new()
```
@return Maid
]=] |
function Maid.new()
return setmetatable({
_tasks = {}
}, Maid)
end
|
--// Positioning |
SprintPos = CFrame.new(0, 0, 0, 0.844756603, -0.251352191, 0.472449303, 0.103136979, 0.942750931, 0.317149073, -0.525118113, -0.219186768, 0.822318792);
|
------------------------- |
while true do
R.BrickColor = BrickColor.new("CGA brown")
wait(0.3)
R.BrickColor = BrickColor.new("Really black")
wait(0.3)
end
|
-- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote |
local emoteNames = { wave = false, point = false, dance = true, dance2 = true, dance3 = true, laugh = false, cheer = false}
math.randomseed(tick())
function configureAnimationSet(name, fileList)
if (animTable[name] ~= nil) then
for _, connection in pairs(animTable[name].connections) do
connection:disconnect()
end
end
animTable[name] = {}
animTable[name].count = 0
animTable[name].totalWeight = 0
animTable[name].connections = {}
local allowCustomAnimations = true
local AllowDisableCustomAnimsUserFlag = true
local success, msg = pcall(function()
AllowDisableCustomAnimsUserFlag = UserSettings():IsUserFeatureEnabled("UserAllowDisableCustomAnims")
end)
if (AllowDisableCustomAnimsUserFlag) then
local ps = game:GetService("StarterPlayer"):FindFirstChild("PlayerSettings")
if (ps ~= nil) then
allowCustomAnimations = not require(ps).UseDefaultAnimations
end
end
-- check for config values
local config = script:FindFirstChild(name)
if (allowCustomAnimations and config ~= nil) then
table.insert(animTable[name].connections, config.ChildAdded:connect(function(child) configureAnimationSet(name, fileList) end))
table.insert(animTable[name].connections, config.ChildRemoved:connect(function(child) configureAnimationSet(name, fileList) end))
local idx = 1
for _, childPart in pairs(config:GetChildren()) do
if (childPart:IsA("Animation")) then
table.insert(animTable[name].connections, childPart.Changed:connect(function(property) configureAnimationSet(name, fileList) end))
animTable[name][idx] = {}
animTable[name][idx].anim = childPart
local weightObject = childPart:FindFirstChild("Weight")
if (weightObject == nil) then
animTable[name][idx].weight = 1
else
animTable[name][idx].weight = weightObject.Value
end
animTable[name].count = animTable[name].count + 1
animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight
idx = idx + 1
end
end
end
-- fallback to defaults
if (animTable[name].count <= 0) then
for idx, anim in pairs(fileList) do
animTable[name][idx] = {}
animTable[name][idx].anim = Instance.new("Animation")
animTable[name][idx].anim.Name = name
animTable[name][idx].anim.AnimationId = anim.id
animTable[name][idx].weight = anim.weight
animTable[name].count = animTable[name].count + 1
animTable[name].totalWeight = animTable[name].totalWeight + anim.weight |
-- Use entrance-easing when adding elements to the view such as a modal or toaster appearing, or moving in response to users’ input, such as dropdown opening or toggle. An element quickly appears and slows down to a stop. |
local EntranceProductive = Bezier(0, 0, 0.38, 0.9)
local EntranceExpressive = Bezier(0, 0, 0.3, 1)
|
-- Roblox character sound script |
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local SOUND_DATA = {
Climbing = {
SoundId = "rbxasset://sounds/action_footsteps_plastic.mp3",
Looped = true,
},
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 = "",
Looped = true,
Pitch = 1.85,
},
Splash = {
SoundId = "rbxasset://sounds/impact_water.mp3",
},
Swimming = {
SoundId = "rbxasset://sounds/action_swim.mp3",
Looped = true,
Pitch = 1.6,
},
}
-- wait for the first of the passed signals to fire
local function waitForFirst(...)
local shunt = Instance.new("BindableEvent")
local slots = {...}
local function fire(...)
for i = 1, #slots do
slots[i]:Disconnect()
end
return shunt:Fire(...)
end
for i = 1, #slots do
slots[i] = slots[i]:Connect(fire)
end
return shunt.Event:Wait()
end
|
--// Recoil Settings |
gunrecoil = -0.2; -- How much the gun recoils backwards when not aiming
camrecoil = 0.2; -- How much the camera flicks when not aiming
AimGunRecoil = -0.2; -- How much the gun recoils backwards when aiming
AimCamRecoil = 0.2; -- How much the camera flicks when aiming
CamShake = 2; -- THIS IS NEW!!!! CONTROLS CAMERA SHAKE WHEN FIRING
AimCamShake = 2; -- THIS IS ALSO NEW!!!!
Kickback = 0.10; -- Upward gun rotation when not aiming
AimKickback = 0.9; -- Upward gun rotation when aiming
|
--[[Engine]] |
--Torque Curve
Tune.Horsepower = 1400
Tune.IdleRPM = 600
Tune.PeakRPM = 7000
Tune.Redline = 8100
Tune.EqPoint = 7000
Tune.PeakSharpness = 9.4
Tune.CurveMult = 0
--Incline Compensation
Tune.InclineComp = 1.7 -- Torque compensation multiplier for inclines (applies gradient from 0-90 degrees)
--Misc
Tune.RevAccel = 450 -- RPM acceleration when clutch is off
Tune.RevDecay = 75 -- RPM decay when clutch is off
Tune.RevBounce = 500 -- RPM kickback from redline
Tune.IdleThrottle = 3 -- Percent throttle at idle
Tune.ClutchTol = 500 -- Clutch engagement threshold (higher = faster response)
|
--Give player when join |
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local equipped = player:WaitForChild("BackpackShop").Equipped
if equipped.Value ~= "" then
local a = game.ServerStorage.Backpacks[equipped.Value]:Clone()
a.Name = "Backpack"
a.Parent = character
else
wait(2)
local a = game.ServerStorage.Backpacks[equipped.Value]:Clone()
a.Name = "Backpack"
a.Parent = character
end
|
------------------------------------------------------------------ |
function FixVars() --This function fixes any errors in the Customize folder
Acceleration2 = (Acceleration.Value < 0 and 0 or Acceleration.Value > 1000 and 1000 or Acceleration.Value)
MaxBank2 = (MaxBank.Value < -90 and -90 or MaxBank.Value > 90 and 90 or MaxBank.Value)
MaxSpeed2 = (MaxSpeed.Value < 0 and 0 or MaxSpeed.Value < StallSpeed.Value and StallSpeed.Value or MaxSpeed.Value)
StallSpeed2 = (StallSpeed.Value < 0 and 0 or StallSpeed.Value > MaxSpeed.Value and MaxSpeed.Value or StallSpeed.Value)
TurnSpeed2 = (TurnSpeed.Value < 0 and 0 or TurnSpeed.Value)
ThrottleInc2 = (ThrottleInc.Value < 0 and 0 or ThrottleInc.Value)
MaxAltitude2 = (MaxAltitude.Value < MinAltitude.Value and MinAltitude.Value or MaxAltitude.Value)
MinAltitude2 = (MinAltitude.Value > MaxAltitude.Value and MaxAltitude.Value or MinAltitude.Value)
MissileTime2 = (ReloadTimes.Missiles.Value < 0 and 0 or ReloadTimes.Missiles.Value)
RocketTime2 = (ReloadTimes.Rockets.Value < 0 and 0 or ReloadTimes.Rockets.Value)
GunTime2 = (ReloadTimes.Guns.Value < 0 and 0 or ReloadTimes.Guns.Value)
FlareTime2 = (ReloadTimes.Flares.Value < 0 and 0 or ReloadTimes.Flares.Value)
BombTime2 = (ReloadTimes.Bombs.Value < 0 and 0 or ReloadTimes.Bombs.Value)
CameraType2 = (pcall(function() Camera.CameraType = CameraType.Value end) and CameraType.Value or "Custom")
PlaneName2 = (PlaneName.Value == "" and "Plane" or PlaneName.Value)
if WeaponsValue.Value then
if WeaponsValue.Missiles.Value or WeaponsValue.Bombs.Value then
Targetable2 = true
elseif (not (WeaponsValue.Missiles.Value and WeaponsValue.Bombs.Value)) then
Targetable2 = false
end
elseif (not WeaponsValue.Value) then
Targetable2 = false
end
if FlightControls.SpeedUp.Value == "ArrowKeyUp" then
SpeedUp2 = 17
SUAK = true
elseif FlightControls.SpeedUp.Value == "ArrowKeyDown" then
SpeedUp2 = 18
SUAK = true
else
SpeedUp2 = FlightControls.SpeedUp.Value
SUAK = false
end
if FlightControls.SlowDown.Value == "ArrowKeyUp" then
SlowDown2 = 17
SDAK = true
elseif FlightControls.SlowDown.Value == "ArrowKeyDown" then
SlowDown2 = 18
SDAK = true
else
SlowDown2 = FlightControls.SlowDown.Value
SDAK = false
end
Engine.Direction.P = TurnSpeed2
end
function FireMachineGun(GunParent) --This function creates the bullets for the MachineGuns
while FiringGun do
for _,v in pairs(GunParent:GetChildren()) do --This is what allow you to put as many MachineGuns as you want in the Guns folder
if v:IsA("BasePart") then
if v.Name == "MachineGun" then
local Part = Instance.new("Part")
Part.BrickColor = BrickColor.new("Bright yellow")
Part.Name = "Bullet"
Part.CanCollide = false
Part.FormFactor = "Symmetric"
Part.Size = Vector3.new(5,5,3)
Part.BottomSurface = "Smooth"
Part.TopSurface = "Smooth"
local Mesh = Instance.new("BlockMesh")
Mesh.Parent = Part
Mesh.Scale = Vector3.new(1/25,1/25,1)
local BV = Instance.new("BodyVelocity")
BV.Parent = Part
BV.maxForce = Vector3.new(math.huge,math.huge,math.huge)
local PlaneTag = Instance.new("ObjectValue")
PlaneTag.Parent = Part
PlaneTag.Name = "PlaneTag"
PlaneTag.Value = Plane
Part.Touched:connect(function(Object) --This lets me call the "Touched" function, which means I don't need an external script
if (not Object:IsDescendantOf(Character)) then
local HitHumanoid = Object.Parent:findFirstChild("Humanoid")
if HitHumanoid then
HitHumanoid:TakeDamage(100) --This only damges the player if they don't have a forcefield
local CreatorTag = Instance.new("ObjectValue")
CreatorTag.Name = "creator"
CreatorTag.Value = Player
CreatorTag.Parent = HitHumanoid
elseif (not HitHumanoid) then
Object:BreakJoints()
end
end
end)
Part.Parent = game.Workspace
Part.CFrame = v.CFrame + v.CFrame.lookVector * 10
BV.velocity = (v.Velocity) + (Part.CFrame.lookVector * 2000) + (Vector3.new(0,0.15,0))
delay(3,function() Part:Destroy() end)
end
end
end
wait(GunTime2)
end
end
function FireRockets(GunParent) --This function creates the rockets for the rocket spawns
for _,v in pairs(GunParent:GetChildren()) do --This allows you to put as many RocketSpawns as you want in the Rockets folder
if v:IsA("BasePart") then
if v.Name == "RocketSpawn" then
local Exploded = false
local Part1 = Instance.new("Part")
Part1.BrickColor = BrickColor.new("White")
Part1.Name = "Missile"
Part1.CanCollide = false
Part1.FormFactor = "Symmetric"
Part1.Size = Vector3.new(1,1,5)
Part1.BottomSurface = "Smooth"
Part1.TopSurface = "Smooth"
local Mesh = Instance.new("SpecialMesh")
Mesh.Parent = Part1
Mesh.MeshId = "http://www.roblox.com/asset/?id=2251534"
Mesh.MeshType = "FileMesh"
Mesh.Scale = Vector3.new(0.5,0.5,0.5)
local Part2 = Instance.new("Part")
Part2.Parent = Part1
Part2.Transparency = 1
Part2.Name = "Visual"
Part2.CanCollide = false
Part2.FormFactor = "Symmetric"
Part2.Size = Vector3.new(1,1,1)
Part2.BottomSurface = "Smooth"
Part2.TopSurface = "Smooth"
local Weld = Instance.new("Weld")
Weld.Parent = Part1
Weld.Part0 = Part1
Weld.Part1 = Part2
Weld.C0 = CFrame.new(0,0,4) * CFrame.Angles(math.rad(90),0,0)
local BV = Instance.new("BodyVelocity")
BV.Parent = Part1
BV.maxForce = Vector3.new(math.huge,math.huge,math.huge)
local BG = Instance.new("BodyGyro")
BG.Parent = Part
BG.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
BG.cframe = v.CFrame
local Fire = Instance.new("Fire")
Fire.Parent = Part2
Fire.Heat = 25
Fire.Size = 10
local Smoke = Instance.new("Smoke")
Smoke.Parent = Part2
Smoke.Color = Color3.new(200/255,200/255,200/255)
Smoke.Opacity = 0.7
Smoke.RiseVelocity = 25
Smoke.Size = 10
local PlaneTag = Instance.new("ObjectValue")
PlaneTag.Parent = Part
PlaneTag.Name = "PlaneTag"
PlaneTag.Value = Plane
Part1.Touched:connect(function(Object)
if (not Exploded) then
if (not Object:IsDescendantOf(Character)) then
if Object.Name ~= "Missile" then
Exploded = true
local Explosion = Instance.new("Explosion",game.Workspace)
Explosion.Position = Part1.Position
Explosion.BlastPressure = 5000
Explosion.BlastRadius = 10
ScanPlayers(Part1.Position,10)
Explosion.Parent = game.Workspace
Part1:Destroy()
end
end
end
end)
Part1.Parent = game.Workspace
Part1.CFrame = v.CFrame + v.CFrame.lookVector * 10
BV.velocity = Part1.CFrame.lookVector * 1250 + Vector3.new(0,0.15,0)
delay(5,function() Part1:Destroy() end)
end
end
end
end
function DeployFlares(GunParent) --This function creates the flares for the flare spawns
for _,v in pairs(GunParent:GetChildren()) do
if v:IsA("BasePart") then
if v.Name == "FlareSpawn" then
local RandomFactor = 40
local RandomX = math.rad(math.random(-RandomFactor,RandomFactor))
local RandomY = math.rad(math.random(-RandomFactor,RandomFactor))
local Part = Instance.new("Part")
Part.Transparency = 1
Part.Name = "Flare"
Part.CanCollide = false
Part.FormFactor = "Symmetric"
Part.Size = Vector3.new(1,1,1)
Part.BottomSurface = "Smooth"
Part.TopSurface = "Smooth"
local BG = Instance.new("BillboardGui")
BG.Parent = Part
BG.Size = UDim2.new(10,0,10,0)
local IL = Instance.new("ImageLabel")
IL.Parent = BG
IL.BackgroundTransparency = 1
IL.Image = "http://www.roblox.com/asset/?id=43708803"
IL.Size = UDim2.new(1,0,1,0)
local Smoke = Instance.new("Smoke")
Smoke.Parent = Part
Smoke.Opacity = 0.5
Smoke.RiseVelocity = 25
Smoke.Size = 5
local PL = Instance.new("PointLight")
PL.Parent = Part
PL.Brightness = 10
PL.Color = Color3.new(1,1,0)
PL.Range = 20
Part.Parent = game.Workspace
Part.CFrame = (v.CFrame + v.CFrame.lookVector * 5) * CFrame.Angles(RandomX,RandomY,0)
Part.Velocity = Part.CFrame.lookVector * 150
delay(5,function() Part:Destroy() end)
end
end
end
end
function DropBomb(GunParent) --This function creates the non-guided bombs for the bomb spawns
if (not Locked) then
for _,v in pairs(GunParent:GetChildren()) do
if v:IsA("BasePart") then
if v.Name == "BombSpawn" then
local Exploded = false
local Part = Instance.new("Part")
Part.Name = "Bomb"
Part.CanCollide = false
Part.FormFactor = "Symmetric"
Part.Size = Vector3.new(2,2,9)
Part.BottomSurface = "Smooth"
Part.TopSurface = "Smooth"
local Mesh = Instance.new("SpecialMesh")
Mesh.Parent = Part
Mesh.MeshId = "http://www.roblox.com/asset/?id=88782666"
Mesh.MeshType = "FileMesh"
Mesh.Scale = Vector3.new(4,4,4)
Mesh.TextureId = "http://www.roblox.com/asset/?id=88782631"
local BG = Instance.new("BodyGyro")
BG.Parent = Part
BG.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
BG.cframe = v.CFrame * CFrame.Angles(math.rad(90),0,0)
local PlaneTag = Instance.new("ObjectValue")
PlaneTag.Parent = Part
PlaneTag.Name = "PlaneTag"
PlaneTag.Value = Plane
Part.Touched:connect(function(Object)
if (not Exploded) then
if (not Object:IsDescendantOf(Character)) and Object.Name ~= "Bomb" then
Exploded = true
local Explosion = Instance.new("Explosion")
Explosion.Position = Part.Position
Explosion.BlastPressure = 500000
Explosion.BlastRadius = 75
ScanPlayers(Part.Position,75)
Explosion.Parent = game.Workspace
Part:Destroy()
end
end
end)
Part.Parent = game.Workspace
Part.CFrame = (v.CFrame * CFrame.Angles(math.rad(90),0,0)) + v.CFrame.lookVector * 3
Part.Velocity = (Part.CFrame.lookVector * (TrueAirSpeed * 0.75))
delay(7,function() Part:Destroy() end)
end
end
end
end
end
function DropGuidedBomb(Gun) --This function creates guided bombs for the bombs spawns
if Locked then
local Exploded = false
local Part = Instance.new("Part")
Part.Name = "Bomb"
Part.CanCollide = false
Part.FormFactor = "Symmetric"
Part.Size = Vector3.new(2,2,9)
Part.BottomSurface = "Smooth"
Part.TopSurface = "Smooth"
local Mesh = Instance.new("SpecialMesh")
Mesh.Parent = Part
Mesh.MeshId = "http://www.roblox.com/asset/?id=88782666"
Mesh.MeshType = "FileMesh"
Mesh.Scale = Vector3.new(4,4,4)
Mesh.TextureId = "http://www.roblox.com/asset/?id=88782631"
local OV = Instance.new("ObjectValue")
OV.Parent = Part
OV.Name = "Tracker"
OV.Value = TargetPlayer.Character.Torso
local NV = Instance.new("NumberValue")
NV.Parent = Part
NV.Name = "PlaneSpd"
NV.Value = TrueAirSpeed * 0.8 --This makes the bombs travel speed 4/5 of the plane's speed
local BG = Instance.new("BodyGyro")
BG.Parent = Part
BG.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
BG.P = 2000
local BV = Instance.new("BodyVelocity")
BV.Parent = Part
BV.maxForce = Vector3.new(math.huge,6000,math.huge)
BV.velocity = Vector3.new(0,0,0)
local Script = BombM:clone()
Script.Parent = Part
local PlaneTag = Instance.new("ObjectValue")
PlaneTag.Parent = Part
PlaneTag.Name = "PlaneTag"
PlaneTag.Value = Plane
Part.Touched:connect(function(Object)
if (not Exploded) then
if (not Object:IsDescendantOf(Character)) and Object.Name ~= "Bomb" then
Exploded = true
local Explosion = Instance.new("Explosion")
Explosion.Position = Part.Position
Explosion.BlastPressure = 500000
Explosion.BlastRadius = 75
ScanPlayers(Part.Position,75)
Explosion.Parent = game.Workspace
Part:Destroy()
end
end
end)
Part.Parent = game.Workspace
Part.CFrame = (Gun.CFrame * CFrame.Angles(math.rad(90),0,0)) + Gun.CFrame.lookVector * 10
Script.Disabled = false
end
end
function FireMissile(Gun) --This function creates the non-guided missiles for the missile spawns
if (not Locked) then
local Exploded = false
local Part1 = Instance.new("Part")
Part1.Name = "Missile"
Part1.CanCollide = false
Part1.FormFactor = "Symmetric"
Part1.Size = Vector3.new(1,1,13)
Part1.BottomSurface = "Smooth"
Part1.TopSurface = "Smooth"
local Mesh = Instance.new("SpecialMesh")
Mesh.Parent = Part1
Mesh.MeshId = "http://www.roblox.com/asset/?id=2251534"
Mesh.MeshType = "FileMesh"
Mesh.TextureId = "http://www.roblox.com/asset/?id=2564491"
local Part2 = Instance.new("Part")
Part2.Parent = Part1
Part2.Name = "Visual"
Part2.Transparency = 1
Part2.CanCollide = false
Part2.FormFactor = "Symmetric"
Part2.Size = Vector3.new(1,1,1)
Part2.BottomSurface = "Smooth"
Part2.TopSurface = "Smooth"
local Weld = Instance.new("Weld")
Weld.Parent = Part1
Weld.Part0 = Part1
Weld.Part1 = Part2
Weld.C0 = CFrame.new(0,0,5)*CFrame.Angles(math.rad(90),0,0)
local BV = Instance.new("BodyVelocity")
BV.Parent = Part1
BV.maxForce = Vector3.new(math.huge,math.huge,math.huge)
local BG = Instance.new("BodyGyro")
BG.Parent = Part
BG.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
BG.cframe = Gun.CFrame * CFrame.Angles(math.rad(90),0,0)
local Fire = Instance.new("Fire")
Fire.Parent = Part2
Fire.Enabled = false
Fire.Heat = 25
Fire.Size = 30
local Smoke = Instance.new("Smoke")
Smoke.Parent = Part2
Smoke.Color = Color3.new(40/51,40/51,40/51)
Smoke.Enabled = false
Smoke.Opacity = 1
Smoke.RiseVelocity = 25
Smoke.Size = 25
local PlaneTag = Instance.new("ObjectValue")
PlaneTag.Parent = Part
PlaneTag.Name = "PlaneTag"
PlaneTag.Value = Plane
Part1.Touched:connect(function(Object)
if (not Exploded) then
if (not Object:IsDescendantOf(Character)) and Object.Name ~= "Missile" then
Exploded = true
local Explosion = Instance.new("Explosion")
Explosion.Position = Part1.Position
Explosion.BlastPressure = 50000
Explosion.BlastRadius = 50
ScanPlayers(Part1.Position,50)
Explosion.Parent = game.Workspace
Part1:Destroy()
end
end
end)
Part1.Parent = game.Workspace
Part1.CFrame = (Gun.CFrame * CFrame.Angles(math.rad(90),0,0)) + Gun.CFrame.lookVector * 15
BV.velocity = Part1.CFrame.lookVector * Engine.Velocity.magnitude
delay(0.3,function()
BV.velocity = (Part1.CFrame.lookVector * 1500) + Vector3.new(0,0.15,0)
Fire.Enabled = true
Smoke.Enabled = true
end)
delay(5,function() Part1:Destroy() end)
end
end
function FireGuidedMissile(Gun) --This function creates the guided missiles for the missile spawns
if Targetable2 then
if Locked then
local Exploded = false
local Part1 = Instance.new("Part")
Part1.Name = "Missile"
Part1.CanCollide = false
Part1.FormFactor = "Symmetric"
Part1.Size = Vector3.new(1,1,13)
Part1.BottomSurface = "Smooth"
Part1.TopSurface = "Smooth"
local Mesh = Instance.new("SpecialMesh")
Mesh.Parent = Part1
Mesh.MeshId = "http://www.roblox.com/asset/?id=2251534"
Mesh.MeshType = "FileMesh"
Mesh.TextureId = "http://www.roblox.com/asset/?id=2564491"
local Part2 = Instance.new("Part")
Part2.Parent = Part1
Part2.Transparency = 1
Part2.Name = "Visual"
Part2.CanCollide = false
Part2.FormFactor = "Symmetric"
Part2.Size = Vector3.new(1,1,1)
Part2.BottomSurface = "Smooth"
Part2.TopSurface = "Smooth"
local Weld = Instance.new("Weld")
Weld.Parent = Part1
Weld.Part0 = Part1
Weld.Part1 = Part2
Weld.C0 = CFrame.new(0,0,5)*CFrame.Angles(math.rad(90),0,0)
local OV = Instance.new("ObjectValue")
OV.Parent = Part1
OV.Name = "Tracker"
OV.Value = TargetPlayer.Character.Torso
local BV = Instance.new("BodyVelocity")
BV.Parent = Part1
BV.maxForce = Vector3.new(math.huge,math.huge,math.huge)
local Script = MissileM:clone()
Script.Parent = Part1
local Fire = Instance.new("Fire")
Fire.Parent = Part2
Fire.Enabled = false
Fire.Heat = 25
Fire.Size = 30
local Smoke = Instance.new("Smoke")
Smoke.Parent = Part2
Smoke.Color = Color3.new(40/51,40/51,40/51)
Smoke.Enabled = false
Smoke.Opacity = 1
Smoke.RiseVelocity = 25
Smoke.Size = 25
local PlaneTag = Instance.new("ObjectValue")
PlaneTag.Parent = Part
PlaneTag.Name = "PlaneTag"
PlaneTag.Value = Plane
Part1.Touched:connect(function(Object)
if (not Exploded) then
if (not Object:IsDescendantOf(Character)) and Object.Name ~= "Missile" then
Exploded = true
local Explosion = Instance.new("Explosion")
Explosion.Position = Part1.Position
Explosion.BlastPressure = 50000
Explosion.BlastRadius = 50
ScanPlayers(Part1.Position,50)
Explosion.Parent = game.Workspace
Part1:Destroy()
end
end
end)
Part1.Parent = game.Workspace
Part1.CFrame = (Gun.CFrame * CFrame.Angles(math.rad(90),0,0)) + Gun.CFrame.lookVector * 15
delay(0.3,function()
Script.Disabled = false
Fire.Enabled = true
Smoke.Enabled = true
end)
delay(10,function() Part1:Destroy() end)
end
end
end
function ScanPlayers(Pos,Radius) --This is a function that I created that efficiently puts a CreatorTag in the player
coroutine.resume(coroutine.create(function()
for i,v in pairs(game.Players:GetPlayers()) do --This gets all the players
if v.Character and v.Character:findFirstChild("Torso") then
local PTorso = v.Character.Torso
if ((PTorso.Position - Pos).magnitude + 2) <= Radius then --If the distance between the explosion and the player is less than the radius...
local HitHumanoid = v.Character:findFirstChild("Humanoid")
if HitHumanoid then
local CreatorTag = Instance.new("ObjectValue")
CreatorTag.Name = "creator"
CreatorTag.Value = Player
CreatorTag.Parent = HitHumanoid
game:GetService("Debris"):AddItem(CreatorTag,0.1)
end
end
end
end
end))
end
function ReloadRocket(Time) --This function reloads the rockets based on the rocket reload time
if (not RocketEnabled) then
wait(Time)
RocketEnabled = true
end
end
function ReloadFlare(Time) --This function reloads the flares based on the flare reload time
if (not FlareEnabled) then
wait(Time)
FlareEnabled = true
end
end
function ReloadBomb(Time) --This function reloads the bombs based on the bomb reload time
if (not BombEnabled) then
wait(Time)
BombEnabled = true
end
end
function ReloadMissile(Time) --This function reloads the missile based on the missile reload time
if (not MissileEnabled) then
wait(Time)
MissileEnabled = true
end
end
function onMouseMoved(mouse) --This function is activated when the mouse moves
if Targetable2 then --If the plane can target...
local Gui = GuiClone.Main
if Targeting then
mouse.Icon = AimingCursor --All the cursors in this script were made by me
Gui.Mode.Text = "Targeting Mode"
local FoundPlayer = false
for i,v in pairs(game.Players:GetPlayers()) do
if v.Character then
if v.Character:findFirstChild("Torso") then
if v ~= Player then
if ((v.TeamColor ~= Player.TeamColor) or v.Neutral) then
local myHead = Character.Head
local TorsoPos = v.Character.Torso.CFrame
local Distance = (myHead.CFrame.p - TorsoPos.p).magnitude
local MouseDirection = (mouse.Hit.p - myHead.CFrame.p).unit
local Offset = (((MouseDirection * Distance) + myHead.CFrame.p) - TorsoPos.p).magnitude
if (not Locked) then
if (Offset/Distance) < 0.1 then
FoundPlayer = true
if TargetPlayer ~= v then
TargetPlayer = v
mouse.Icon = TargetCursor
AimGui.Enabled = true
LockGui.Enabled = false
AimGui.Adornee = TargetPlayer.Character.Torso
LockGui.Adornee = nil
end
end
if (not FoundPlayer) and TargetPlayer then
TargetPlayer = nil
mouse.Icon = AimingCursor
AimGui.Enabled = false
LockGui.Enabled = false
AimGui.Adornee = nil
LockGui.Adornee = nil
end
elseif Locked then
mouse.Icon = LockedCursor
AimGui.Enabled = false
LockGui.Enabled = true
AimGui.Adornee = nil
LockGui.Adornee = TargetPlayer.Character.Torso
end
end
end
end
end
end
elseif (not Targeting) then
mouse.Icon = NormalCursor
Gui.Mode.Text = "Flying Mode"
end
end
end
function onButton1Down(mouse) --This function is activated when you press the left mouse button
Locked = ((not Locked) and TargetPlayer and Targeting and EngineOn and Targeting2)
end
function IncreaseSpd() --This function increases the speed
if EngineOn then
if Selected then
while Accelerating do
Throttle = (Throttle < 1 and Throttle + 0.01 or 1)
DesiredSpeed = MaxSpeed2 * Throttle
wait(ThrottleInc2)
end
end
end
end
function DecreaseSpd() --This function decreases the speed
if EngineOn then
if Selected then
while Decelerating do
Throttle = (Throttle > 0 and Throttle - 0.01 or 0)
DesiredSpeed = MaxSpeed2 * Throttle
wait(ThrottleInc2)
end
end
end
end
function RoundNumber(Num) --This function rounds a number to the nearest whole number
return ((Num - math.floor(Num)) >= 0.5 and math.ceil(Num) or math.floor(Num))
end
function GetGear(Parent) --This function gets all the parts in the Gear folder
for i,v in pairs(Parent:GetChildren()) do
if (v:IsA("BasePart")) then
if (not v:findFirstChild("GearProp")) then
local GearProp = Instance.new("StringValue")
GearProp.Name = "GearProp"
GearProp.Value = v.Transparency..","..tostring(v.CanCollide)
GearProp.Parent = v
end
table.insert(LandingGear,v) --This inserts a table with the gear's properties into the LandingGear table
end
GetGear(v)
end
end
function ChangeGear() --This function extends or retracts the gear
for i,v in pairs(LandingGear) do
local GearProp = v.GearProp
local Comma = GearProp.Value:find(",",1,true)
local TransVal = tonumber(GearProp.Value:sub(1,Comma - 1))
local CollideVal = GearProp.Value:sub(Comma + 1)
v.Transparency = (TransVal ~= 1 and (GearUp and TransVal or 1))
v.CanCollide = (CollideVal and (GearUp and CollideVal or false))
end
end
function SetUpGui() --This function sets up the PlaneGui
local Gui = GuiClone.Main
Gui.Title.Text = PlaneName2
local TargetStats = Gui.Parent.Target
local HUD = Gui.Parent.HUD
local ControlsA,ControlsB = Gui.ControlsA,Gui.ControlsB
local FrameA,FrameB = Gui.FrameA,Gui.FrameB
local C1A,C1B = FrameA.C1.Key,FrameB.C1.Key
local C2A,C2B = FrameA.C2.Key,FrameB.C2.Key
local C3A,C3B = FrameA.C3.Key,FrameB.C3.Key
local C4A,C4B = FrameA.C4.Key,FrameB.C4.Key
local C5A,C5B = FrameA.C5.Key,FrameB.C5.Key
local C6,C7 = FrameA.C6.Key,FrameA.C7.Key
local GearText = Gui.Gear
for i,v in pairs(LandingGear) do --This section determines whether the gear are up or down
if v.Transparency == 1 then
GearUp = true
else
GearUp = false
break
end
end
local MaxSpeedScaled = math.ceil(MaxSpeed2/50)
for i = 1,(MaxSpeedScaled + 10) do --This creates a loop that clones the SpeedGui and positions it accordingly
local SpeedGui = HUD.Speed.Main
local Speed0 = SpeedGui["Speed-0"]
local SpeedClone = Speed0:clone()
SpeedClone.Position = UDim2.new(0,0,1,-(80 + (75 * i)))
SpeedClone.Name = ("Speed-%i"):format(50 * i)
SpeedClone.Text.Text = tostring(50 * i)
SpeedClone.Parent = SpeedGui
end
local MaxAltScaled = math.ceil(MaxAltitude2/500)
for i = 1,(MaxAltScaled + 10) do --This creates a loop that clones the AltitudeGui and positions it accordingly
local AltGui = HUD.Altitude.Main
local Altitude0 = AltGui["Altitude-0"]
local AltClone = Altitude0:clone()
AltClone.Position = UDim2.new(0,0,1,-(80 + (75 * i)))
AltClone.Name = ("Altitude-%s"):format(tostring(0.5 * i))
AltClone.Text.Text = tostring(0.5 * i)
AltClone.Parent = AltGui
end
GearText.Text = (GearUp and "Gear Up" or "Gear Down")
C1A.Text = "Key: "..FlightControls.Engine.Value:upper()
if FlightControls.SpeedUp.Value == "ArrowKeyUp" then
C2A.Text = "Key: ArrowKeyUp"
elseif FlightControls.SpeedUp.Value == "ArrowKeyDown" then
C2A.Text = "Key: ArrowKeyDown"
else
C2A.Text = "Key: "..FlightControls.SpeedUp.Value:upper()
end
if FlightControls.SlowDown.Value == "ArrowKeyUp" then
C3A.Text = "Key: ArrowKeyUp"
elseif FlightControls.SlowDown.Value == "ArrowKeyDown" then
C3A.Text = "Key: ArrowKeyDown"
else
C3A.Text = "Key: "..FlightControls.SlowDown.Value:upper()
end
C4A.Text = "Key: "..FlightControls.Gear.Value:upper()
if Targetable2 then
C5A.Text = "Key: "..TargetControls.Modes.Value:upper()
else
C5A.Parent.Visible = false
end
if Ejectable.Value then
C6.Text = "Key: "..FlightControls.Eject.Value:upper()
else
C6.Parent.Visible = false
end
if CamLock.Value then
C7.Text = "Key: "..FlightControls.LockCam.Value:upper()
else
C7.Parent.Visible = false
end
if (not WeaponsValue.Value) then
C1B.Parent.Visible = false
C2B.Parent.Visible = false
C3B.Parent.Visible = false
C4B.Parent.Visible = false
C5B.Parent.Visible = false
FrameB.Title.Text = "No Weapons"
elseif WeaponsValue.Value then
if WeaponsValue.Missiles.Value then
C1B.Text = "Key: "..WeaponControls.FireMissile.Value:upper()
elseif (not WeaponsValue.Missiles.Value) then
C1B.Parent.Visible = false
end
if WeaponsValue.Rockets.Value then
C2B.Text = "Key: "..WeaponControls.FireRockets.Value:upper()
elseif (not WeaponsValue.Rockets.Value) then
C2B.Parent.Visible = false
end
if WeaponsValue.Guns.Value then
C3B.Text = "Key: "..WeaponControls.FireGuns.Value:upper()
elseif (not WeaponsValue.Guns.Value) then
C3B.Parent.Visible = false
end
if WeaponsValue.Bombs.Value then
C4B.Text = "Key: "..WeaponControls.DropBombs.Value:upper()
elseif (not WeaponsValue.Bombs.Value) then
C4B.Parent.Visible = false
end
if WeaponsValue.Flares.Value then
C5B.Text = "Key: "..WeaponControls.DeployFlares.Value:upper()
elseif (not WeaponsValue.Flares.Value) then
C5B.Parent.Visible = false
end
end
ControlsA.MouseButton1Click:connect(function() --This function allows the Flight Controls frame to be opened or closed without an external script
if GuiAVisible then
GuiAVisible = false
FrameA:TweenPosition(UDim2.new(0,150,0,-190),"In","Quad",1,true)
elseif (not GuiAVisible) then
GuiAVisible = true
FrameA:TweenPosition(UDim2.new(0,150,0,170),"Out","Quad",1,true)
end
end)
ControlsB.MouseButton1Click:connect(function()
if GuiBVisible then
GuiBVisible = false
FrameB:TweenPosition(UDim2.new(0,-150,0,-150),"In","Quad",1,true)
elseif (not GuiBVisible) then
GuiBVisible = true
FrameB:TweenPosition(UDim2.new(0,-150,0,170),"Out","Quad",1,true)
end
end)
end
function GetRoll(CF) --This function gets the rotation of the Engine. Credit to DevAdrian for this
local CFRight = CF * CFrame.Angles(0,math.rad(90),0)
local CFNoRollRight = CFrame.new(CF.p,CF.p + CF.lookVector) * CFrame.Angles(0,math.rad(90),0)
local CFDiff = CFRight:toObjectSpace(CFNoRollRight)
return (-math.atan2(CFDiff.lookVector.Y, CFDiff.lookVector.Z) % (math.pi * 2) + math.pi)
end
function GetPitch(CF) --This function gets the pitch of the Engine. Credit to DevAdrian for this
local LV = CF.lookVector
local XZDist = math.sqrt(LV.x^2 + LV.z^2)
return math.atan(LV.y / XZDist)
end
function UpdateCamera() --This function uses the RunService to update the camera. It happens very fast so it is smooth
if Selected then
if (not LockedCam) then
Camera.CameraType = CameraType2
elseif LockedCam then
local HeadCF = Character.Head.CFrame
local PlaneSize = Plane:GetModelSize().magnitude/3
local Origin = HeadCF.p + (HeadCF.lookVector * (PlaneSize - 1))
local Target = HeadCF.p + (HeadCF.lookVector * PlaneSize)
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CoordinateFrame = CFrame.new(Origin,Target)
Camera:SetRoll(GetRoll(Character.Head.CFrame))
end
else
Camera.CameraType = Enum.CameraType.Custom
end
end
function UpdateTargetStats(Target,Gui) --This function updates the stats about the Target
if Target then
local myHead = Character.Head
local TorsoPos = Target.Character.Torso.CFrame
local Distance = (myHead.CFrame.p - TorsoPos.p).magnitude
local TargetSpeed = (Target.Character.Torso.Velocity).magnitude
local TargetAlt = Target.Character.Torso.Position.Y
Gui.LockName.Text = ("Target: %s"):format(Target.Name)
Gui.Dist.Text = ("Distance: %s"):format(tostring(math.floor(Distance * 10)/10))
Gui.Speed.Text = ("Speed: %s"):format(tostring(math.floor(TargetSpeed * 10)/10))
Gui.Altitude.Text = ("Altitude: %s"):format(tostring(math.floor(TargetAlt * 10)/10))
elseif (not Target) then
Gui.LockName.Text = "Target: None"
Gui.Dist.Text = "Distance: N/A"
Gui.Speed.Text = "Speed: N/A"
Gui.Altitude.Text = "Altitude: N/A"
end
end
function UpdateHUD(Gui) --This function updates the HUD whenever the camera is locked
Gui.Roll.Rotation = math.deg(GetRoll(Character.Head.CFrame))
local PitchNum = math.deg(GetPitch(Character.Head.CFrame))/90
Gui.Roll.Pitch.Position = UDim2.new(0,-200,0,-500 + (PitchNum * 450))
local SpeedScaled = TrueAirSpeed/50
Gui.Speed.Main.Position = UDim2.new(0,0,0.5,SpeedScaled * 75)
Gui.Speed.Disp.Text.Text = RoundNumber(TrueAirSpeed)
local AltScaled = RoundNumber(Engine.Position.Y)/500
Gui.Altitude.Main.Position = UDim2.new(0,0,0.5,AltScaled * 75)
Gui.Altitude.Disp.Text.Text = RoundNumber(Engine.Position.Y)
local NegFactor = (Engine.Velocity.y/math.abs(Engine.Velocity.y))
local VerticalSpeed = RoundNumber(math.abs(Engine.Velocity.y))
Gui.ClimbRate.Text = ("VSI: %i"):format(VerticalSpeed * NegFactor)
Gui.GearStatus.Text = (GearUp and "Gear Up" or "Gear Down")
Gui.GearStatus.TextColor3 = (GearUp and Color3.new(0,1,0) or Color3.new(1,0,0))
Gui.EngineStatus.Text = (EngineOn and "Engine On" or "Engine Off")
Gui.EngineStatus.TextColor3 = (EngineOn and Color3.new(0,1,0) or Color3.new(1,0,0))
Gui.StallWarn.Visible = ((not Taxi()) and Stall())
Gui.PullUp.Visible = (EngineOn and (not Taxi()) and (AltRestrict.Value) and (Engine.Position.Y < (MinAltitude2 + 20)))
Gui.TaxiStatus.Visible = (Engine and Taxi())
Gui.Throttle.Bar.Tray.Position = UDim2.new(0,0,1,-(Throttle * 460))
Gui.Throttle.Bar.Tray.Size = UDim2.new(1,0,0,(Throttle * 460))
Gui.Throttle.Disp.Text = math.abs(math.floor(Throttle * 100)).."%"
local StallLinePos = (StallSpeed2/math.floor(TrueAirSpeed + 0.5)) * (StallSpeed2/MaxSpeed2)
local StallLinePosFix = (StallLinePos > 1 and 1 or StallLinePos < 0 and 0 or StallLinePos)
Gui.Throttle.Bar.StallLine.Position = UDim2.new(0,0,1 - StallLinePosFix,0)
Gui.Throttle.Bar.Tray.BackgroundColor3 = (Throttle <= StallLinePosFix and Color3.new(1,0,0) or Color3.new(0,1,0))
end
function UpdateGui(Taxiing,Stalling) --This function updates the gui.
local Gui = GuiClone.Main
local TargetStats = GuiClone.Target
local HUD = Player.PlayerGui.PlaneGui.HUD
Gui.Visible = ((not HUDOnLock.Value) or (HUDOnLock.Value and (not LockedCam)))
HUD.Visible = (LockedCam and HUDOnLock.Value)
if LockedCam and HUDOnLock.Value then UpdateHUD(HUD) end
if Targetable2 then UpdateTargetStats(TargetPlayer,TargetStats) end
Gui.PullUp.Visible = (EngineOn and (not Taxiing) and (AltRestrict.Value) and (Engine.Position.Y < (MinAltitude2 + 20)))
Gui.Taxi.Visible = (EngineOn and Taxiing)
Gui.Stall.Visible = ((not Taxiing) and Stalling)
Gui.Altitude.Text = "Altitude: "..RoundNumber(Engine.Position.Y)
Gui.Speed.Text = "Speed: "..RoundNumber(TrueAirSpeed)
Gui.Throttle.Bar.Tray.Size = UDim2.new(Throttle,0,1,0)
Gui.Throttle.Percent.Text = math.abs(math.floor(Throttle * 100)).."%"
local StallLinePos = (StallSpeed2/math.floor(TrueAirSpeed + 0.5)) * (StallSpeed2/MaxSpeed2)
local StallLinePosFix = (StallLinePos > 1 and 1 or StallLinePos < 0 and 0 or StallLinePos)
Gui.Throttle.Bar.StallLine.Position = UDim2.new(StallLinePosFix,0,0,0)
Gui.Throttle.Bar.Tray.BackgroundColor3 = (Throttle <= StallLinePosFix and Color3.new(1,0,0) or Color3.new(0,2/3,0))
end
function CalculateSpeed() --This function calculates the current speed
while Selected do
if EngineOn then
CurrentSpeed = (CurrentSpeed < DesiredSpeed and CurrentSpeed + 2 or CurrentSpeed - 2) --A simple ternary operation that calculates the currentspeed
CurrentSpeed = (CurrentSpeed < 0 and 0 or CurrentSpeed > MaxSpeed2 and MaxSpeed2 or CurrentSpeed) --This fixes the currentspeed
end
wait(0.5 - (Acceleration2/2000))
end
end
function GetLowestPoint() --This function gets the lowest point of the plane
if (#LandingGear == 0) then
LowestPoint = (Engine.Position.Y + 5 + (Engine.Size.Y/2))
return
end
for i,v in pairs(LandingGear) do
local Set0 = (Engine.Position.Y - (v.CFrame * CFrame.new((v.Size.X/2),0,0)).Y)
local Set1 = (Engine.Position.Y - (v.CFrame * CFrame.new(-(v.Size.X/2),0,0)).Y)
local Set2 = (Engine.Position.Y - (v.CFrame * CFrame.new(0,(v.Size.Y/2),0)).Y)
local Set3 = (Engine.Position.Y - (v.CFrame * CFrame.new(0,-(v.Size.Y/2),0)).Y)
local Set4 = (Engine.Position.Y - (v.CFrame * CFrame.new(0,0,(v.Size.Z/2))).Y)
local Set5 = (Engine.Position.Y - (v.CFrame * CFrame.new(0,0,-(v.Size.Z/2))).Y)
local Max = (math.max(Set0,Set1,Set2,Set3,Set4,Set5) + 5)
LowestPoint = (Max > LowestPoint and Max or LowestPoint)
end
end
function GetBankAngle(M) --This function calculates the Bank Angle
local VSX,X = M.ViewSizeX,M.X
local Ratio = (((VSX/2) - X)/(VSX/2))
Ratio = (Ratio < -1 and -1 or Ratio > 1 and 1 or Ratio)
return math.rad(Ratio * MaxBank2)
end
function Taxi() --This function determines whether the plane is taxiing or not
local Ray = Ray.new(Engine.Position,Vector3.new(0,-LowestPoint,0))
return (TrueAirSpeed <= StallSpeed2 and game.Workspace:FindPartOnRay(Ray,Plane))
end
function Stall() --This function determines whether the plane is stalling or not
return ((AltRestrict.Value and Engine.Position.Y > MaxAltitude2) or TrueAirSpeed < StallSpeed2)
end
function FlyMain(M) --This is the main flying function
if Selected then
local BankAngle = GetBankAngle(M) --This uses the "GetBankAngle" function to calculate the Bank Angle
local Taxi,Stall = Taxi(),Stall()
if EngineOn then
Engine.Thrust.velocity = (Engine.CFrame.lookVector * CurrentSpeed) + Vector3.new(0,0.15,0)
if Taxi then
if (CurrentSpeed < 2) then
Thrust.maxForce = Vector3.new(0,0,0)
Direction.maxTorque = Vector3.new(0,0,0)
else
Thrust.maxForce = Vector3.new(math.huge,0,math.huge)
Direction.maxTorque = Vector3.new(0,math.huge,0)
Direction.cframe = CFrame.new(Engine.Position,M.Hit.p)
end
elseif Stall then
Thrust.maxForce = Vector3.new(0,0,0)
Direction.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
Direction.cframe = (M.Hit*CFrame.Angles(0,0,BankAngle))
else
Thrust.maxForce = Vector3.new(math.huge,math.huge,math.huge)
Direction.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
Direction.cframe = (M.Hit*CFrame.Angles(0,0,BankAngle))
end
if ((AltRestrict.Value) and (Engine.Position.Y < MinAltitude2)) then --If there are altitude restrictions and you are below it...
AutoCrash.Value = true
end
elseif (not EngineOn) then
Thrust.maxForce = Vector3.new(0,0,0)
Thrust.velocity = Vector3.new(0,0,0)
Direction.maxTorque = Vector3.new(0,0,0)
end
TrueAirSpeed = Engine.Velocity.magnitude
UpdateGui(Taxi,Stall) --This activates the "UpdateGui" function]]
wait()
end
end
function onKeyDown(Key) --This function is activated whenever a key is pressed
Key:lower()
if (Key == FlightControls.Engine.Value) then --If you press the engine key...
local Gui = GuiClone.Main
if (not EngineOn) then
EngineOn = true
DesiredSpeed = 0
CurrentSpeed = 0
Throttle = 0
Gui.Engine.Visible = false
CalculateSpeed()
elseif EngineOn then
EngineOn = false
DesiredSpeed = 0
CurrentSpeed = 0
Throttle = 0
Gui.Engine.Visible = true
end
end
if (Key == FlightControls.Gear.Value) then --If you press the change gear key...
local Gui = GuiClone.Main
local Taxiing = Taxi()
if (#LandingGear ~= 0) then
if (not Taxiing) then
ChangeGear()
if (not GearUp) then
GearUp = true
Gui.Gear.Text = "Gear Up"
elseif GearUp then
GearUp = false
Gui.Gear.Text = "Gear Down"
end
end
end
end
if SUAK and Key:byte() == SpeedUp2 or (not SUAK) and (Key == SpeedUp2) then --If you press the speed up key...
Accelerating = true
IncreaseSpd()
end
if SDAK and Key:byte() == SlowDown2 or (not SDAK) and (Key == SlowDown2) then --If you press the slow down key...
Decelerating = true
DecreaseSpd()
end
if (Key == TargetControls.Modes.Value) then --If you press the change modes key...
if Targetable2 then
if EngineOn then
if (not Targeting) then
Targeting = true
elseif Targeting then
Targeting = false
Locked = false
AimGui.Enabled = false
LockGui.Enabled = false
end
end
end
end
if (Key == FlightControls.Eject.Value:lower()) then
if EngineOn then
local Taxiing = Taxi()
if (not Taxiing) then
if Ejectable.Value then
if (not Plane.Ejected.Value) then
Plane.Ejected.Value = true
local Seat = MainParts.Seat
local EjectClone = Tool.Ejector:clone()
EjectClone.Parent = Player.PlayerGui
EjectClone.Disabled = false
local Fire = Instance.new("Fire")
Fire.Parent = Engine
Fire.Heat = 25
Fire.Size = 30
local Smoke = Instance.new("Smoke")
Smoke.Parent = Engine
Smoke.Color = Color3.new(1/3,1/3,1/3)
Smoke.Opacity = 0.7
Smoke.RiseVelocity = 10
Smoke.Size = 10
Seat.SeatWeld:remove()
end
end
end
end
end
if (Key == FlightControls.LockCam.Value) then
LockedCam = (not LockedCam)
end
if (Key == WeaponControls.FireGuns.Value) then --If you press the fire guns key...
if WeaponsValue.Value then --If there are weapons...
if WeaponsValue.Guns.Value then --If there are guns...
if EngineOn then
local Taxiing = Taxi()
if (not Taxiing) then --This prevents you from firing the gun while your on the ground
FiringGun = true
FireMachineGun(Weapons) --This activates the "FireMachineGun" function
end
end
end
end
end
if (Key == WeaponControls.FireRockets.Value) then --If you press the fire rockets key...
if WeaponsValue.Value then
if WeaponsValue.Rockets.Value then
local Taxiing = Taxi()
if (not Taxiing) then
if RocketEnabled then
RocketEnabled = false
FireRockets(Weapons)
ReloadRocket(RocketTime2)
end
end
end
end
end
if (Key == WeaponControls.DeployFlares.Value) then --If you press the deploy flares key...
if WeaponsValue.Value then
if WeaponsValue.Flares.Value then
if EngineOn then
local Taxiing = Taxi()
if (not Taxiing) then
if FlareEnabled then --This makes the plane deploy flares 5 times every 0.2 seconds before you have to reload
FlareEnabled = false
for i = 1,5 do
DeployFlares(Weapons)
wait(0.2)
end
ReloadFlare(FlareTime2)
end
end
end
end
end
end
if (Key == WeaponControls.DropBombs.Value) then --If you press the drop bombs key...
if WeaponsValue.Value then
if WeaponsValue.Bombs.Value then
if EngineOn then
local Taxiing = Taxi()
if (not Taxiing) then
if BombEnabled then
BombEnabled = false
local BombSpawns = {}
for i,v in pairs(Weapons:GetChildren()) do
if v:IsA("BasePart") then
if v.Name == "BombSpawn" then
table.insert(BombSpawns,v)
end
end
end
local CurrentSpawn = BombSpawns[math.random(1,#BombSpawns)] --This line selects a random bomb spawn
if Locked then
DropGuidedBomb(CurrentSpawn)
ReloadBomb((BombTime2 * 2))
elseif (not Locked) then
for i = 1,5 do
DropBomb(Weapons)
wait(0.3)
end
ReloadBomb(BombTime2)
end
end
end
end
end
end
end
if (Key == WeaponControls.FireMissile.Value) then --If you press the fire missile key...
if WeaponsValue.Value then
if WeaponsValue.Missiles.Value then
if EngineOn then
local Taxiing = Taxi()
if (not Taxiing) then
if MissileEnabled then
MissileEnabled = false
local MissileSpawns = {}
for i,v in pairs(Weapons:GetChildren()) do
if v:IsA("BasePart") then
if v.Name == "MissileSpawn" then
table.insert(MissileSpawns,v)
end
end
end
local CurrentSpawn = MissileSpawns[math.random(1,#MissileSpawns)] --This line selects a random missile spawn
if Locked then
FireGuidedMissile(CurrentSpawn)
ReloadMissile((MissileTime2 * 2))
elseif (not Locked) then
FireMissile(CurrentSpawn)
ReloadMissile(MissileTime2)
end
end
end
end
end
end
end
if (Key == TargetControls.UnTarget.Value) then --If you press the untarget key...
if Targetable2 then
if Locked then
Locked = false
end
end
end
end
function onKeyUp(Key) --This function is activated when you let go of a key
Key:lower()
if SUAK and Key:byte() == SpeedUp2 or (not SUAK) and (Key == SpeedUp2) then --If you let go of the speed up key...
Accelerating = false
end
if SDAK and Key:byte() == SlowDown2 or (not SDAK) and (Key == SlowDown2) then --If you let go of the slow down key...
Decelerating = false
end
if (Key == WeaponControls.FireGuns.Value) then --If you let go of the fire guns key...
FiringGun = false
end
end
function onSelected(mouse) --This function is activated when you select the Plane tool
Selected = true
mouse2 = mouse
FixVars() --This activates the "FixVars" function
GetGear(Gear) --This activates the "GetGear" function
GetLowestPoint() --This activates the "GetLowestPoint" function
ToolSelect.Value = true
GuiClone = GUI:clone() --This line and the next one clones the plane gui and puts it into the player
GuiClone.Parent = Player.PlayerGui
SetUpGui() --This activates the "SetUpGui" function
Camera.CameraType = CameraType2 --This makes your cameratype the customize cameratype
if Targetable2 then --If the plane can target, then it will create the objects required for targeting
AimGui = Instance.new("BillboardGui",Player.PlayerGui)
AimGui.AlwaysOnTop = true
AimGui.Enabled = false
AimGui.Size = UDim2.new(0,50,0,50)
local Label = Instance.new("ImageLabel",AimGui)
Label.BackgroundTransparency = 1
Label.Image = "http://www.roblox.com/asset/?id=107388694"
Label.Size = UDim2.new(1,0,1,0)
LockGui = Instance.new("BillboardGui",Player.PlayerGui)
LockGui.AlwaysOnTop = true
LockGui.Enabled = false
LockGui.Size = UDim2.new(0,50,0,50)
local Label = Instance.new("ImageLabel",LockGui)
Label.BackgroundTransparency = 1
Label.Image = "http://www.roblox.com/asset/?id=107388656"
Label.Size = UDim2.new(1,0,1,0)
end
mouse.Icon = NormalCursor
FTab[1] = mouse.Move:connect(function() onMouseMoved(mouse) end) --Lines 1025-1029 activate the given functions
FTab[2] = mouse.Idle:connect(function() onMouseMoved(mouse) end)
FTab[3] = mouse.Button1Down:connect(function() onButton1Down(mouse) end)
FTab[4] = mouse.KeyDown:connect(onKeyDown)
FTab[5] = mouse.KeyUp:connect(onKeyUp)
FTab[6] = RunService.RenderStepped:connect(UpdateCamera)
FTab[7] = RunService.Stepped:connect(function() FlyMain(mouse) end)
end
function onDeselected(mouse) --This function is activated when you deselect the Plane tool
Selected = false
LockedCam = false
for i,v in pairs(FTab) do --This disconnects all the connections. It prevents bugs
if v then
v:disconnect()
end
end
Camera.CameraType = Enum.CameraType.Custom --This makes the CameraType "Custom"
Camera.CameraSubject = Character.Humanoid
if Targetable2 then --If the plane can target, then the objects required for targeting will be removed
AimGui:remove()
LockGui:remove()
end
if (not Taxi()) and EngineOn then --If you're not Taxiing and your engine is on...
if (not Deselect0.Value) and (not Plane.Ejected.Value) then --If you deselected the tool and didn't eject...
onDeselectFlying()
end
end
CurrentSpeed = 0 --Lines 1041-1054 resets the plane, the plane gui, and the plane tool
DesiredSpeed = 0
TrueAirSpeed = 0
EngineOn = false
Updating = false
Locked = false
Targeting = false
TargetPlayer = nil
ToolSelect.Value = false
GuiAVisible = true
GuiBVisible = true
GuiClone:remove()
Engine.Thrust.velocity = Vector3.new(0,0,0)
Engine.Thrust.maxForce = Vector3.new(0,0,0)
Engine.Direction.maxTorque = Vector3.new(0,0,0)
end
function onDeselectFlying() --This function blows up the plane
if (not Deselect0.Value) then
local Explosion = Instance.new("Explosion")
Explosion.Parent = game.Workspace
Explosion.Position = Engine.Position
Explosion.BlastRadius = Plane:GetModelSize().magnitude
Explosion.BlastPressure = 100000
Character.Humanoid.Health = 0
Engine.Thrust:remove()
Engine.Direction:remove()
delay(5,function()
Plane:Destroy()
end)
end
end
function onDeselectForced() --This function is activated when you get out of the plane without deselecting the tool first
if Deselect0.Value then
onDeselected()
mouse2.Icon = "rbxasset://textures\\ArrowCursor.png" --This makes the mouse icon the normal icon
end
end
script.Parent.Selected:connect(onSelected) --The next 3 lines activate the given functions
script.Parent.Deselected:connect(onDeselected)
Deselect0.Changed:connect(onDeselectForced)
|
--// All global vars will be wiped/replaced except script |
return function(data, env)
if env then
setfenv(1, env)
end
local gui = client.UI.Prepare(script.Parent.Parent) -- Change it to a TextLabel to avoid chat clearing
local playergui = service.PlayerGui
local frame = gui.Frame
local msg = gui.Frame.Message
local ttl = gui.Frame.Title
local gIndex = data.gIndex
local gTable = data.gTable
local title = data.Title
local message = data.Message
local scroll = data.Scroll
local tim = data.Time
if not data.Message or not data.Title then gui:Destroy() end
ttl.Text = title
msg.Text = message
ttl.TextTransparency = 1
msg.TextTransparency = 1
ttl.TextStrokeTransparency = 1
msg.TextStrokeTransparency = 1
frame.BackgroundTransparency = 1
local blur = service.New("BlurEffect")
blur.Enabled = false
blur.Size = 0
blur.Parent = workspace.CurrentCamera
local fadeSteps = 10
local blurSize = 10
local textFade = 0.1
local strokeFade = 0.5
local frameFade = 0.3
local blurStep = blurSize/fadeSteps
local frameStep = frameFade/fadeSteps
local textStep = 0.1
local strokeStep = 0.1
local gone = false
local function fadeIn()
if not gone then
blur.Enabled = true
gTable:Ready()
--gui.Parent = service.PlayerGui
for i = 1,fadeSteps do
if blur.Size<blurSize then
blur.Size = blur.Size+blurStep
end
if msg.TextTransparency>textFade then
msg.TextTransparency = msg.TextTransparency-textStep
ttl.TextTransparency = ttl.TextTransparency-textStep
end
if msg.TextStrokeTransparency>strokeFade then
msg.TextStrokeTransparency = msg.TextStrokeTransparency-strokeStep
ttl.TextStrokeTransparency = ttl.TextStrokeTransparency-strokeStep
end
if frame.BackgroundTransparency>frameFade then
frame.BackgroundTransparency = frame.BackgroundTransparency-frameStep
end
wait(1/60)
end
end
end
local function fadeOut()
if not gone then
for i = 1,fadeSteps do
if blur.Size>0 then
blur.Size = blur.Size-blurStep
end
if msg.TextTransparency<1 then
msg.TextTransparency = msg.TextTransparency+textStep
ttl.TextTransparency = ttl.TextTransparency+textStep
end
if msg.TextStrokeTransparency<1 then
msg.TextStrokeTransparency = msg.TextStrokeTransparency+strokeStep
ttl.TextStrokeTransparency = ttl.TextStrokeTransparency+strokeStep
end
if frame.BackgroundTransparency<1 then
frame.BackgroundTransparency = frame.BackgroundTransparency+frameStep
end
wait(1/60)
end
blur.Enabled = false
blur:Destroy()
service.UnWrap(gui):Destroy()
gone = true
end
end
gTable.CustomDestroy = function()
if not gone then
gone = true
pcall(fadeOut)
end
pcall(function() service.UnWrap(gui):Destroy() end)
pcall(function() blur:Destroy() end)
end
--[[if not scroll then
msg.Text = message
else
Routine(function()
wait(0.5)
for i = 1, #message do
msg.Text = msg.Text .. message:sub(i,i)
wait(0.05)
end
end)
end--]] -- For now?
fadeIn()
wait(tim or 5)
if not gone then
fadeOut()
end
--[[
frame.Position = UDim2.new(0.5,-175,-1.5,0)
gui.Parent = playergui
frame:TweenPosition(UDim2.new(0.5,-175,0.25,0),nil,nil,0.5)
if not scroll then
msg.Text = message
wait(tim or 10)
else
wait(0.5)
for i = 1, #message do
msg.Text = msg.Text .. message:sub(i,i)
wait(0.05)
end
wait(tim or 5)
end
if frame then
frame:TweenPosition(UDim2.new(0.5,-175,-1.5,0),nil,nil,0.5)
wait(1)
gui:Destroy()
end
--]]
end
|
-- spring for an array of linear values |
local LinearSpring = {} do
LinearSpring.__index = LinearSpring
function LinearSpring.new(dampingRatio, frequency, pos, typedat, rawTarget)
local linearPos = typedat.toIntermediate(pos)
return setmetatable(
{
d = dampingRatio,
f = frequency,
g = linearPos,
p = linearPos,
v = table.create(#linearPos, 0),
typedat = typedat,
rawTarget = rawTarget,
},
LinearSpring
)
end
function LinearSpring:setGoal(goal)
self.rawTarget = goal
self.g = self.typedat.toIntermediate(goal)
end
function LinearSpring:canSleep()
if magnitudeSq(self.v) > SLEEP_VELOCITY_SQ_LIMIT then
return false
end
if distanceSq(self.p, self.g) > SLEEP_OFFSET_SQ_LIMIT then
return false
end
return true
end
function LinearSpring:step(dt)
-- Advance the spring simulation by dt seconds.
-- Take the damped harmonic oscillator ODE:
-- f^2*(X[t] - g) + 2*d*f*X'[t] + X''[t] = 0
-- Where X[t] is position at time t, g is target position,
-- f is undamped angular frequency, and d is damping ratio.
-- Apply constant initial conditions:
-- X[0] = p0
-- X'[0] = v0
-- Solve the IVP to get analytic expressions for X[t] and X'[t].
-- The solution takes one of three forms for 0<=d<1, d=1, and d>1
local d = self.d
local f = self.f*2*pi -- Hz -> Rad/s
local g = self.g
local p = self.p
local v = self.v
if d == 1 then -- critically damped
local q = exp(-f*dt)
local w = dt*q
local c0 = q + w*f
local c2 = q - w*f
local c3 = w*f*f
for idx = 1, #p do
local o = p[idx] - g[idx]
p[idx] = o*c0 + v[idx]*w + g[idx]
v[idx] = v[idx]*c2 - o*c3
end
elseif d < 1 then -- underdamped
local q = exp(-d*f*dt)
local c = sqrt(1 - d*d)
local i = cos(dt*f*c)
local j = sin(dt*f*c)
-- Damping ratios approaching 1 can cause division by very small numbers.
-- To mitigate that, group terms around z=j/c and find an approximation for z.
-- Start with the definition of z:
-- z = sin(dt*f*c)/c
-- Substitute a=dt*f:
-- z = sin(a*c)/c
-- Take the Maclaurin expansion of z with respect to c:
-- z = a - (a^3*c^2)/6 + (a^5*c^4)/120 + O(c^6)
-- z ≈ a - (a^3*c^2)/6 + (a^5*c^4)/120
-- Rewrite in Horner form:
-- z ≈ a + ((a*a)*(c*c)*(c*c)/20 - c*c)*(a*a*a)/6
local z
if c > EPS then
z = j/c
else
local a = dt*f
z = a + ((a*a)*(c*c)*(c*c)/20 - c*c)*(a*a*a)/6
end
-- Frequencies approaching 0 present a similar problem.
-- We want an approximation for y as f approaches 0, where:
-- y = sin(dt*f*c)/(f*c)
-- Substitute b=dt*c:
-- y = sin(b*c)/b
-- Now reapply the process from z.
local y
if f*c > EPS then
y = j/(f*c)
else
local b = f*c
y = dt + ((dt*dt)*(b*b)*(b*b)/20 - b*b)*(dt*dt*dt)/6
end
for idx = 1, #p do
local o = p[idx] - g[idx]
p[idx] = (o*(i + z*d) + v[idx]*y)*q + g[idx]
v[idx] = (v[idx]*(i - z*d) - o*(z*f))*q
end
else -- overdamped
local c = sqrt(d*d - 1)
local r1 = -f*(d - c)
local r2 = -f*(d + c)
local ec1 = exp(r1*dt)
local ec2 = exp(r2*dt)
for idx = 1, #p do
local o = p[idx] - g[idx]
local co2 = (v[idx] - o*r1)/(2*f*c)
local co1 = ec1*(o - co2)
p[idx] = co1 + co2*ec2 + g[idx]
v[idx] = co1*r1 + co2*ec2*r2
end
end
return self.typedat.fromIntermediate(self.p)
end
end
local function inverseGammaCorrectD65(c)
return c < 0.0404482362771076 and c/12.92 or 0.87941546140213*(c + 0.055)^2.4
end
local function gammaCorrectD65(c)
return c < 3.1306684425e-3 and 12.92*c or 1.055*c^(1/2.4) - 0.055
end
local function rgbToLuv(value)
-- convert RGB to a variant of cieluv space
local r, g, b = value.R, value.G, value.B
-- D65 sRGB inverse gamma correction
r = inverseGammaCorrectD65(r)
g = inverseGammaCorrectD65(g)
b = inverseGammaCorrectD65(b)
-- sRGB -> xyz
local x = 0.9257063972951867*r - 0.8333736323779866*g - 0.09209820666085898*b
local y = 0.2125862307855956*r + 0.71517030370341085*g + 0.0722004986433362*b
local z = 3.6590806972265883*r + 11.4426895800574232*g + 4.1149915024264843*b
-- xyz -> scaled cieluv
local l = y > 0.008856451679035631 and 116*y^(1/3) - 16 or 903.296296296296*y
local u, v
if z > 1e-14 then
u = l*x/z
v = l*(9*y/z - 0.46832)
else
u = -0.19783*l
v = -0.46832*l
end
return {l, u, v}
end
local function luvToRgb(value)
-- convert back from modified cieluv to rgb space
local l = value[1]
if l < 0.0197955 then
return Color3.new(0, 0, 0)
end
local u = value[2]/l + 0.19783
local v = value[3]/l + 0.46832
-- cieluv -> xyz
local y = (l + 16)/116
y = y > 0.206896551724137931 and y*y*y or 0.12841854934601665*y - 0.01771290335807126
local x = y*u/v
local z = y*((3 - 0.75*u)/v - 5)
-- xyz -> D65 sRGB
local r = 7.2914074*x - 1.5372080*y - 0.4986286*z
local g = -2.1800940*x + 1.8757561*y + 0.0415175*z
local b = 0.1253477*x - 0.2040211*y + 1.0569959*z
-- clamp minimum sRGB component
if r < 0 and r < g and r < b then
r, g, b = 0, g - r, b - r
elseif g < 0 and g < b then
r, g, b = r - g, 0, b - g
elseif b < 0 then
r, g, b = r - b, g - b, 0
end
-- gamma correction from D65
-- clamp to avoid undesirable overflow wrapping behavior on certain properties (e.g. BasePart.Color)
return Color3.new(
min(gammaCorrectD65(r), 1),
min(gammaCorrectD65(g), 1),
min(gammaCorrectD65(b), 1)
)
end
|
-- Helper functions |
function angleBetweenPoints(p0, p1)
local p = p0 - p1
return -math.atan2(p.z, p.x)
end
function getCameraAngle(camera)
local cf, f = camera.CoordinateFrame, camera.Focus
return angleBetweenPoints(cf.p, f.p)
end
|
-- ROBLOX deviation: alias for internal React$ flow types |
export type React_Node =
nil
| boolean
| number
| string
| React_Element<any>
-- ROBLOX TODO: only include this once it's more specific than `any`
-- | React_Portal
| Array<React_Node?>
-- ROBLOX TODO Luau: this more closely matches the upstream Iterable<>, hypothetically the UNIQUE_TAG field makes it so we don't unify with other tables and squad field resolution
| { [string]: React_Node?, UNIQUE_TAG: any? }
export type React_Element<ElementType> = {
type: ElementType,
props: React_ElementProps<ElementType>?,
key: React_Key | nil,
ref: any,
}
export type React_PureComponent<Props, State = nil> = React_Component<Props, State>
|
--// Dump log on disconnect |
local isStudio = game:GetService("RunService"):IsStudio()
game:GetService("NetworkClient").ChildRemoved:Connect(function(p)
if not isStudio then
warn("~! PLAYER DISCONNECTED/KICKED! DUMPING ADONIS CLIENT LOG!")
dumplog()
end
end)
local unique = {}
local origEnv = getfenv()
setfenv(1, setmetatable({}, { __metatable = unique })) |
--!strict |
local function defaultFilter(...: any)
return true
end
local function onSpawned<U>(parent: Instance, callback: (child: U) -> (), filter: ((child: Instance) -> boolean)?)
local filterer = (filter or defaultFilter) :: (Instance) -> boolean
for _, child in parent:GetChildren() :: { any } do
if filterer(child) then
task.spawn(callback, child)
end
end
local signal = parent.ChildAdded:Connect(function(child: any)
if filterer(child) then
callback(child)
end
end)
return function()
signal:Disconnect()
end
end
return onSpawned
|
--[[Drivetrain]] |
Tune.Config = "FWD" --"FWD" , "RWD" , "AWD"
|
------------------------------------------------------------------------
-- parse function declaration body
-- * used in simpleexp(), localfunc(), funcstat()
------------------------------------------------------------------------ |
function luaY:body(ls, e, needself, line)
-- body -> '(' parlist ')' chunk END
local new_fs = {} -- FuncState
new_fs.upvalues = {}
new_fs.actvar = {}
self:open_func(ls, new_fs)
new_fs.f.lineDefined = line
self:checknext(ls, "(")
if needself then
self:new_localvarliteral(ls, "self", 0)
self:adjustlocalvars(ls, 1)
end
self:parlist(ls)
self:checknext(ls, ")")
self:chunk(ls)
new_fs.f.lastlinedefined = ls.linenumber
self:check_match(ls, "TK_END", "TK_FUNCTION", line)
self:close_func(ls)
self:pushclosure(ls, new_fs, e)
end
|
-- end |
end
end)
keyset.Event:wait()
script.Parent.Key.Transparency=0
_G.Tween(script.Parent.Key,{CFrame=script.Parent.KeyC.CFrame},1,"Sine","In"):Play()
wait(1.2)
script.Parent.Key.ClickDetector.MaxActivationDistance=10
script.Parent.KeyBase.ClickDetector.MaxActivationDistance=0
script.Parent.Key.ClickDetector.MouseClick:Wait()
_G.Tween(script.Parent.Key,{CFrame=script.Parent.KeyO.CFrame},0.3,"Quad"):Play()
_G.Tween(script.Parent.KeyHole,{CFrame=script.Parent.KeyHoleO.CFrame},0.3,"Quad"):Play()
script.Parent.KeyBase.Key:Play()
wait(0.5)
local Value = Instance.new("CFrameValue")
Value.Value=script.Parent.CoverC.CFrame
Value.Changed:connect(function()
script.Parent.Cover:SetPrimaryPartCFrame(Value.Value)
end)
_G.Tween(Value,{Value=script.Parent.CoverO.CFrame},0.8,"Bounce","Out"):Play()
wait(1)
script.Parent.Indicator.Color=Color3.new(0,1,0)
script.Parent.Button.ClickDetector.MouseClick:Wait()
script.Parent.Indicator.Color=Color3.new(1,0,0)
script.Parent.Button.Sound:Play()
_G.Tween(script.Parent.Button.Mesh,{Offset=Vector3.new(0.15,0,0)},0.2,"Quad","InOut",true):Play()
_G.Tween(Value,{Value=script.Parent.CoverC.CFrame},2,"Quad"):Play()
workspace.UPCCoreSystemUNYv4yvw3789n5yw7ay.ReactorStartup.Disabled=false
wait(2.5)
script.Parent.Key.ClickDetector.MaxActivationDistance=0
_G.Tween(script.Parent.Key,{CFrame=script.Parent.KeyC.CFrame},0.3,"Quad"):Play()
_G.Tween(script.Parent.KeyHole,{CFrame=script.Parent.KeyHoleC.CFrame},0.3,"Quad"):Play()
script.Parent.KeyBase.Key:Play()
wait(0.5)
_G.Tween(script.Parent.Key,{CFrame=script.Parent.KeyC.CFrame*CFrame.new(0,0.5,0)},1,"Sine"):Play()
wait(1)
script.Parent.Key.Transparency=1
|
--[[Controls]] |
local _CTRL = _Tune.Controls
local Controls = Instance.new("Folder",script.Parent)
Controls.Name = "Controls"
for i,v in pairs(_CTRL) do
local a=Instance.new("StringValue",Controls)
a.Name=i
a.Value=v.Name
a.Changed:connect(function()
if i=="MouseThrottle" or i=="MouseBrake" then
if a.Value == "MouseButton1" or a.Value == "MouseButton2" then
_CTRL[i]=Enum.UserInputType[a.Value]
else
_CTRL[i]=Enum.KeyCode[a.Value]
end
else
_CTRL[i]=Enum.KeyCode[a.Value]
end
end)
end
|
--[[
for a,b in pairs(game.ServerScriptService.MainModule.Server.Morphs:GetDescendants()) do
if b:IsA("Decal") and b.Name ~= "face" and b.Parent.Name == "Head" then
print("CHANGED: ".. b.Name.." | "..b.Parent.Parent.Name)
b.Name = "face"
end
end
--]] |
local bundleCache = {} -- cache HumanoidDescriptions retrieved from bundles to reduce API calls
function module:ApplyBundle(humanoid, bundleId)
local HumanoidDescription = bundleCache[bundleId]
if not HumanoidDescription then
local success, bundleDetails = pcall(function() return main.assetService:GetBundleDetailsAsync(bundleId) end)
if success and bundleDetails then
for _, item in next, bundleDetails.Items do
if item.Type == "UserOutfit" then
success, HumanoidDescription = pcall(function() return main.players:GetHumanoidDescriptionFromOutfitId(item.Id) end)
bundleCache[bundleId] = HumanoidDescription
break
end
end
end
end
if not HumanoidDescription then return end
local newDescription = humanoid:GetAppliedDescription()
local defaultDescription = Instance.new("HumanoidDescription")
for _, property in next, {"BackAccessory", "BodyTypeScale", "ClimbAnimation", "DepthScale", "Face", "FaceAccessory", "FallAnimation", "FrontAccessory", "GraphicTShirt", "HairAccessory", "HatAccessory", "Head", "HeadColor", "HeadScale", "HeightScale", "IdleAnimation", "JumpAnimation", "LeftArm", "LeftArmColor", "LeftLeg", "LeftLegColor", "NeckAccessory", "Pants", "ProportionScale", "RightArm", "RightArmColor", "RightLeg", "RightLegColor", "RunAnimation", "Shirt", "ShouldersAccessory", "SwimAnimation", "Torso", "TorsoColor", "WaistAccessory", "WalkAnimation", "WidthScale"} do
if HumanoidDescription[property] ~= defaultDescription[property] then -- property is not the default value
newDescription[property] = HumanoidDescription[property]
end
end
humanoid:ApplyDescription(newDescription)
end
return module
|
-- Get references to the DockShelf and its children |
local dockShelf = script.Parent.Parent.Parent.Parent.Parent.DockShelf
local shlf = script.Parent.Parent.Parent.Parent.Parent.WindowManager.CtxtMenu
local aFinderButton = shlf.About
local Minimalise = script.Parent
local window = script.Parent.Parent.Parent
|
--[[Susupension]] |
Tune.SusEnabled = true -- works only in with PGSPhysicsSolverEnabled, defaults to false when PGS is disabled
--Front Suspension
Tune.FSusDamping = 500 -- Spring Dampening
Tune.FSusStiffness = 9000 -- Spring Force
Tune.FAntiRoll = 50 -- Anti-Roll (Gyro Dampening)
Tune.FSusLength = 1 -- Suspension length (in studs)
Tune.FPreCompress = .3 -- Pre-compression adds resting length force
Tune.FExtensionLim = .3 -- Max Extension Travel (in studs)
Tune.FCompressLim = .1 -- Max Compression Travel (in studs)
Tune.FSusAngle = 80 -- Suspension Angle (degrees from horizontal)
Tune.FWsBoneLen = 5 -- Wishbone Length
Tune.FWsBoneAngle = 0 -- Wishbone angle (degrees from horizontal)
Tune.FAnchorOffset = { -- Suspension anchor point offset (relative to center of wheel)
--[[Lateral]] -.4 , -- positive = outward
--[[Vertical]] -.5 , -- positive = upward
--[[Forward]] 0 } -- positive = forward
--Rear Suspension
Tune.RSusDamping = 500 -- Spring Dampening
Tune.RSusStiffness = 9000 -- Spring Force
Tune.FAntiRoll = 50 -- Anti-Roll (Gyro Dampening)
Tune.RSusLength = 1 -- Suspension length (in studs)
Tune.RPreCompress = .3 -- Pre-compression adds resting length force
Tune.RExtensionLim = .3 -- Max Extension Travel (in studs)
Tune.RCompressLim = .1 -- Max Compression Travel (in studs)
Tune.RSusAngle = 80 -- Suspension Angle (degrees from horizontal)
Tune.RWsBoneLen = 5 -- Wishbone Length
Tune.RWsBoneAngle = 0 -- Wishbone angle (degrees from horizontal)
Tune.RAnchorOffset = { -- Suspension anchor point offset (relative to center of wheel)
--[[Lateral]] -.4 , -- positive = outward
--[[Vertical]] -.5 , -- positive = upward
--[[Forward]] 0 } -- positive = forward
--Aesthetics
Tune.SusVisible = false -- Spring Visible
Tune.WsBVisible = false -- Wishbone Visible
Tune.SusRadius = .2 -- Suspension Coil Radius
Tune.SusThickness = .1 -- Suspension Coil Thickness
Tune.SusColor = "Bright red" -- Suspension Color [BrickColor]
Tune.SusCoilCount = 6 -- Suspension Coil Count
Tune.WsColor = "Black" -- Wishbone Color [BrickColor]
Tune.WsThickness = .1 -- Wishbone Rod Thickness
|
-- Defaultly Changes Color |
give.BrickColor = SC
color.BrickColor = SC
|
--PUT THIS SCRIPT IN STARTERPACK, STOP DISLIKING IT BECAUSE YOU DIDN'T USE IT RIGHT |
local sounds = game:GetService('SoundService')
local runtime = game:GetService('RunService')
script:WaitForChild('FootstepSounds').Parent = sounds
local materials = sounds:WaitForChild('FootstepSounds')
local plr = game.Players.LocalPlayer
repeat wait() until plr.Character
local char = plr.Character
local hrp = char.HumanoidRootPart
local hum = char.Humanoid
local walking
hum.Running:connect(function(speed)
if speed > hum.WalkSpeed/2 then
walking = true
else
walking = false
end
end)
function getMaterial()
local floormat = hum.FloorMaterial
if not floormat then floormat = 'Air' end
local matstring = string.split(tostring(floormat),'Enum.Material.')[2]
local material = matstring
return material
end
local lastmat
runtime.Heartbeat:connect(function()
if walking then
local material = getMaterial()
if material ~= lastmat and lastmat ~= nil then
materials[lastmat].Playing = false
end
local materialSound = materials[material]
materialSound.PlaybackSpeed = hum.WalkSpeed/12
materialSound.Playing = true
lastmat = material
else
for _,sound in pairs(materials:GetChildren()) do
sound.Playing = false
end
end
end)
|
-- m.DesiredAngle = -1
-- script.Parent.Parent.DoorOpen:Play() |
end
end
end)
|
-- [[ Flags ]] |
local FFlagUserCameraGamepadZoomFix
do
local success, result = pcall(function()
return UserSettings():IsUserFeatureEnabled("UserCameraGamepadZoomFix")
end)
FFlagUserCameraGamepadZoomFix = success and result
end
|
-- Enable this if you want to test ragdolls in zero - g |
local buildRagdoll = require(ReplicatedStorage:WaitForChild("buildRagdoll"))
|
--Variables |
local player = game.Players.LocalPlayer
local open = false
|
--//wipers |
local wpr = Instance.new("Motor", script.Parent.Parent.Misc.WPR.SS)
wpr.MaxVelocity = 0.05
wpr.Part0 = script.Parent.WPR
wpr.Part1 = wpr.Parent
local wpr2 = Instance.new("Motor", script.Parent.Parent.Misc.WPR2.SS)
wpr2.MaxVelocity = 0.05
wpr2.Part0 = script.Parent.WPR2
wpr2.Part1 = wpr2.Parent
|
-- Don't edit below unless you know what you're doing. |
local O = true
function onClicked()
if O == true then
O = false
One()
elseif O == false then
O = true
Two()
end
end
script.Parent.MouseButton1Down:connect(onClicked)
|
-- grab the mouse |
local mouse = localPlayer:GetMouse()
|
-- 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
function Icon:give(userdata)
local valueToGive = userdata
if typeof(userdata) == "function" then
local returnValue = userdata(self)
if typeof(userdata) ~= "function" then
valueToGive = returnValue
end
end
self._maid:give(valueToGive)
return self
end
|
--step 3: move your ScreenGui to the "Part" inside "Model" (you can re-name the part whatever and the ScreenGui) | |
-- The script needs this to check the state to not update the Last Standing Y Position Variable. |
local function getHumanoidState(h)
return h:GetState()
end
|
-- Gets the closest player within range to the given mob. If the closest player is the player the mob is already following, distance is 2x.
-- Note: If streaming is enabled, MoveTo may produce undesired results if the max distance is ever higher than streaming minimum, such as the enemy
-- appearing to 'idle' if the current distance/magnitude is between the streaming minimum and the max follow distance (including 2x possibility) |
function AI:GetClosestPlayer(Mob: MobList.Mob): (Player?, number?)
local Closest = {Player = nil, Magnitude = math.huge}
local ActivePlayer -- We retain a reference to this, so they have to get further away from the mob to stop following, instead of the usual distance.
if Mob.Enemy.WalkToPart then
local Player = Players:GetPlayerFromCharacter(Mob.Enemy.WalkToPart.Parent)
if Player then
ActivePlayer = Player
end
end
for _, Player in Players:GetPlayers() do
local Character = Player.Character
if not Character then continue end
local Magnitude = (Character:GetPivot().Position - Mob.Instance:GetPivot().Position).Magnitude
local MaxDistance = (ActivePlayer == Player and (Mob.Config.FollowDistance or 32) * 2) or Mob.Config.FollowDistance or 32
if Magnitude <= MaxDistance and Magnitude < Closest.Magnitude then
Closest.Player = Player
Closest.Magnitude = Magnitude
end
end
return Closest.Player, Closest.Player and Closest.Magnitude
end
|
--///////////////////////// Constructors
--////////////////////////////////////// |
function module.new()
local obj = setmetatable({}, methods)
obj.MessageIdCounter = 0
obj.ChatChannels = {}
obj.Speakers = {}
obj.FilterMessageFunctions = Util:NewSortedFunctionContainer()
obj.ProcessCommandsFunctions = Util:NewSortedFunctionContainer()
obj.eChannelAdded = Instance.new("BindableEvent")
obj.eChannelRemoved = Instance.new("BindableEvent")
obj.eSpeakerAdded = Instance.new("BindableEvent")
obj.eSpeakerRemoved = Instance.new("BindableEvent")
obj.ChannelAdded = obj.eChannelAdded.Event
obj.ChannelRemoved = obj.eChannelRemoved.Event
obj.SpeakerAdded = obj.eSpeakerAdded.Event
obj.SpeakerRemoved = obj.eSpeakerRemoved.Event
obj.ChatServiceMajorVersion = 0
obj.ChatServiceMinorVersion = 5
return obj
end
return module.new()
|
--[=[
Counts the number of times a char appears in a string.
:::note
Note that this is not UTF8 safe
:::
@param str string
@param char string
@return number
]=] |
function String.checkNumOfCharacterInString(str: string, char: string): number
local count = 0
for _ in string.gmatch(str, char) do
count = count + 1
end
return count
end
|
--[=[
@prop Player Player
@within KnitClient
@readonly
Reference to the LocalPlayer.
]=] |
KnitClient.Player = game:GetService("Players").LocalPlayer
|