prompt
stringlengths 2
14.7k
| completion
stringlengths 1
99.7k
|
---|---|
--edit the below function to execute code when this response is chosen OR this prompt is shown
--player is the player speaking to the dialogue, and dialogueFolder is the object containing the dialogue data
|
return function(plr, dialogueFolder)
local Checkpoints = workspace:WaitForChild("Checkpoints")
local Stage = plr:WaitForChild("leaderstats"):WaitForChild("Stage").Value
Stage -= 1
local char = plr.Character
char:WaitForChild("HumanoidRootPart")
char:WaitForChild("Head")
char:WaitForChild("Humanoid")
char:PivotTo(CFrame.new(Checkpoints[Stage].Position + Vector3.new(0,6,0)))
wait()
char:PivotTo(CFrame.new(Checkpoints[Stage].Position + Vector3.new(0,6,0)))
end
|
------------
|
Player.Character.Torso["Right Shoulder"]:destroy()
glue11 = Instance.new("Glue", Player.Character.Torso)
glue11.Part0 = Player.Character.Torso
glue11.Part1 = rightrm
glue11.Name = "Right shoulder"
collider11 = Instance.new("Part", rightrm)
collider11.Position = Vector3.new(0,9999,0)
collider11.Size = Vector3.new(1.8,1,1)
collider11.Shape = "Cylinder"
local weld11 = Instance.new("Weld", collider11)
weld11.Part0 = rightrm
weld11.Part1 = collider11
weld11.C0 = CFrame.new(0,-0.2,0) * CFrame.fromEulerAnglesXYZ(0, 0, math.pi/2)
collider11.TopSurface = "Smooth"
collider11.BottomSurface = "Smooth"
collider11.formFactor = "Symmetric"
glue11.C0 = CFrame.new(1.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
glue11.C1 = CFrame.new(0, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
collider11.Transparency = 1
|
-- map check loop then
|
if not RunService:IsStudio() then
NewMap()
end
while true do
local NextMap = CheckNextMap() and (not RunService:IsStudio())
if NextMap or FORCED_MAP ~= '' then
NewMap()
end
task.wait(1)
end
|
-- ANIMATION
|
function stopAllAnimations()
local oldAnim = currentAnim
currentAnim = ""
currentAnimInstance = nil
if (currentAnimKeyframeHandler ~= nil) then
currentAnimKeyframeHandler:disconnect()
end
if (currentAnimTrack ~= nil) then
currentAnimTrack:Stop()
currentAnimTrack:Destroy()
currentAnimTrack = nil
end
-- clean up walk if there is one
if (runAnimKeyframeHandler ~= nil) then
runAnimKeyframeHandler:disconnect()
end
if (runAnimTrack ~= nil) then
runAnimTrack:Stop()
runAnimTrack:Destroy()
runAnimTrack = 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
if currentAnim == "walk" then
runAnimTrack.TimePosition = 0.0
currentAnimTrack.TimePosition = 0.0
else
local repeatAnim = currentAnim
local animSpeed = currentAnimSpeed
playAnimation(repeatAnim, 0.15, Humanoid)
setAnimationSpeed(animSpeed)
end
end
end
function rollAnimation(animName)
local roll = math.random(1, animTable[animName].totalWeight)
local origRoll = roll
local idx = 1
while (roll > animTable[animName][idx].weight) do
roll = roll - animTable[animName][idx].weight
idx = idx + 1
end
return idx
end
function playAnimation(animName, transitionTime, humanoid)
local idx = rollAnimation(animName)
local anim = animTable[animName][idx].anim
-- switch animation
if (anim ~= currentAnimInstance) then
if (currentAnimTrack ~= nil) then
currentAnimTrack:Stop(transitionTime)
currentAnimTrack:Destroy()
end
if (runAnimTrack ~= nil) then
runAnimTrack:Stop(transitionTime)
runAnimTrack:Destroy()
end
currentAnimSpeed = 1.0
-- load it to the humanoid; get AnimationTrack
currentAnimTrack = humanoid:LoadAnimation(anim)
-- play the animation
currentAnimTrack:Play(transitionTime)
currentAnim = animName
currentAnimInstance = anim
-- set up keyframe name triggers
if (currentAnimKeyframeHandler ~= nil) then
currentAnimKeyframeHandler:disconnect()
end
currentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)
end
end
|
-- Variables
|
if script.Parent.Damage.Value < 1 then
local Vehicle = script.Parent
print("Vehicle Destroy Script Enabled")
local Engine = Vehicle.Parts.Engine
Vehicle:findFirstChild("Destroyed").Value = true
-- Seat Variables
Vehicle.Parts:findFirstChild("VehicleSeat").Disabled = true
-- End of Seat Variables
|
-- Place this in your car model
|
local model = script.Parent
model:MakeJoints()
script.Disabled = true
script:Destroy()
|
-- Camera Shake Instance
-- Stephen Leitnick
-- February 26, 2018
| |
-- Ring4 descending
|
for l = 1,#lifts4 do
if (lifts4[l].className == "Part") then
lifts4[l].BodyPosition.position = Vector3.new((lifts4[l].BodyPosition.position.x),(lifts4[l].BodyPosition.position.y-6),(lifts4[l].BodyPosition.position.z))
end
end
wait(0.1)
for p = 1,#parts4 do
parts4[p].CanCollide = false
end
wait(0.1)
|
--[=[
Constructs a new Maid which will clean up when the brio dies.
Will error if the Brio is dead.
:::info
Calling this while the brio is already dead will throw a error.
:::
```lua
local brio = Brio.new("a")
local maid = brio:ToMaid()
maid:GiveTask(function()
print("Cleaning up!")
end)
brio:Kill() --> Cleaning up!
```
@return Maid
]=]
|
function Brio:ToMaid()
assert(self._values ~= nil, "Brio is dead")
local maid = Maid.new()
maid:GiveTask(self:GetDiedSignal():Connect(function()
maid:DoCleaning()
end))
return maid
end
function Brio:ToMaidAndValue()
return self:ToMaid(), self:GetValue()
end
|
--HeroThPianist
|
local tool = script.Parent.Parent
local event = script.Parent:WaitForChild("PepperSprayEvent")
event.OnServerEvent:connect(function(plr,event,arg1,arg2,arg3)
if event == "Button1Down" then
tool.Spray.Transparency = 1
tool.Spray.Script.Disabled = false
tool.Nossle.Spray.Enabled = true
tool.Nossle.Sound:Play()
elseif event == "Button1Up" then
tool.Spray.Transparency = 1
tool.Spray.Script.Disabled = true
tool.Nossle.Spray.Enabled = false
tool.Nossle.Sound:Stop()
end
end)
|
-- TODO: Consider moving wagon sell requests to this module
|
return MarketClient
|
-- Library
|
local List = {}
function List.Create(list, max, fillDirection, padding, instanceFunc)
max = max or math.huge
padding = padding or UDim.new(0, 0)
fillDirection = fillDirection or Enum.FillDirection.Vertical
instanceFunc = instanceFunc or defaultButton
local nList = #list
local dList = 1 / nList
local isVertical = (fillDirection == Enum.FillDirection.Vertical)
local listFrame = Instance.new("Frame")
listFrame.Name = "ListFrame"
listFrame.BorderSizePixel = 0
local scrollFrame = Instance.new("ScrollingFrame")
scrollFrame.Name = "ScrollFrame"
scrollFrame.BackgroundTransparency = 1
scrollFrame.BorderSizePixel = 0
scrollFrame.Size = UDim2.new(1, 0, 1, 0)
local canvasSize = nil
local elementSize = nil
local extraPosition = nil
local adj = (nList - 1) / nList
local scale = padding.Scale * adj
local offset = padding.Offset * adj
if (isVertical) then
canvasSize = UDim2.new(0, 0, nList / max, 0)
elementSize = UDim2.new(1, 0, dList - scale, -offset)
else
canvasSize = UDim2.new(nList / max , 0, 0, 0)
elementSize = UDim2.new(dList - scale, -offset, 1, 0)
end
scrollFrame.CanvasSize = canvasSize
local items = {}
for i, option in ipairs(list) do
local item = instanceFunc(i, option)
item.LayoutOrder = i
item.Size = elementSize
item.Position = UDim2.new(0, 0, (i-1)*dList, 0)
if (isVertical) then
item.Position = item.Position + UDim2.new(0, 0, padding.Scale/nList*(i-1), padding.Offset/nList*(i-1))
else
item.Position = item.Position + UDim2.new(padding.Scale/nList*(i-1), padding.Offset/nList*(i-1), 0, 0)
end
items[i] = item
item.Parent = scrollFrame
end
listFrame.BackgroundTransparency = items[1].BackgroundTransparency
listFrame.BackgroundColor3 = items[1].BackgroundColor3
scrollFrame.Parent = listFrame
return listFrame
end
|
--This Removes The Error From The Script To Make It work.
| |
--// Declarables
|
local L_15_ = false
local L_16_ = false
local L_17_ = true
local L_18_ = L_1_:WaitForChild('Resource')
local L_19_ = L_18_:WaitForChild('FX')
local L_20_ = L_18_:WaitForChild('Events')
local L_21_ = L_18_:WaitForChild('HUD')
local L_22_ = L_18_:WaitForChild('Modules')
local L_23_ = L_18_:WaitForChild('SettingsModule')
local L_24_ = require(L_23_:WaitForChild("ClientConfig"))
local L_25_ = L_18_:WaitForChild('Vars')
local L_26_
local L_27_
local L_28_
local L_29_
local L_30_
local L_31_
local L_32_
local L_33_
local L_34_
local L_35_
local L_36_
local L_37_
local L_38_
local L_39_
local L_40_
local L_41_
local L_42_
local L_43_
local L_44_
local L_45_
local L_46_
local L_47_
local L_48_
local L_49_
local L_50_ = L_24_.AimZoom
local L_51_ = L_24_.MouseSensitivity
local L_52_ = L_12_.MouseDeltaSensitivity
local L_53_ = game.ReplicatedStorage:FindFirstChild('SoundIso_Network') or nil
local L_54_
if L_53_ then
L_54_ = L_53_:WaitForChild('EventConnection')
end
|
-- Setting these here so the functions above can self-reference just by name:
|
MockDataStoreUtils.logMethod = logMethod
MockDataStoreUtils.deepcopy = deepcopy
MockDataStoreUtils.scanValidity = scanValidity
MockDataStoreUtils.getStringPath = getStringPath
MockDataStoreUtils.importPairsFromTable = importPairsFromTable
MockDataStoreUtils.prepareDataStoresForExport = prepareDataStoresForExport
MockDataStoreUtils.preprocessKey = preprocessKey
MockDataStoreUtils.accurateWait = accurateWait
MockDataStoreUtils.simulateYield = simulateYield
MockDataStoreUtils.simulateErrorCheck = simulateErrorCheck
return MockDataStoreUtils
|
--[[ The Module ]]
|
--
local BaseOcclusion = {}
BaseOcclusion.__index = BaseOcclusion
setmetatable(BaseOcclusion, { __call = function(_, ...) return BaseOcclusion.new(...) end})
function BaseOcclusion.new()
local self = setmetatable({}, BaseOcclusion)
return self
end
|
--[=[
Takes in a data type, and returns it in array form.
```lua
local str = "Test"
print(TableKit.From(str)) -- prints ("T", "e", "s", t")
```
@within TableKit
@param value unknown
@return { [number]: unknown }
]=]
|
function TableKit.From(value: any): { any }
local valueType = typeof(value)
if valueType == "string" then
return string.split(value, "")
elseif valueType == "Color3" then
return { value.R, value.G, value.B }
elseif valueType == "Vector2" then
return { value.X, value.Y }
elseif valueType == "Vector3" then
return { value.X, value.Y, value.Z }
elseif valueType == "NumberSequence" then
return value.Keypoints
elseif valueType == "Vector3int16" then
return { value.X, value.Y, value.Z }
elseif valueType == "Vector2int16" then
return { value.X, value.Y }
else
return { value }
end
end
|
--!strict
-- upstream: https://github.com/facebook/react/blob/6faf6f5eb1705eef39a1d762d6ee381930f36775/packages/shared/objectIs.js
--[[*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
]]
| |
-- ATS 1.2.2
--------------------------------------------------------------------------------------------------
|
local P = script.Parent
local Run = game:GetService('RunService')
local wheels = P.Wheels
local seat = P.Body.VehicleSeat
local vars = seat.ATSVariables
local exclude = {"Wheels"}
function WeldPair(x, y)
local weld = Instance.new("Weld",x)
weld.Part0 = x
weld.Part1 = y
weld.C1 = y.CFrame:toObjectSpace(x.CFrame);
end
function WeldAll(model, main) -- model can be anything
for i,v in pairs(exclude) do if (model.Name == v) then return end end
if model:IsA("BasePart") then WeldPair(main, model) end
for _,v in pairs(model:GetChildren()) do WeldAll(v, main) end
end
function UnanchorAll(model) -- model can be anything
if (model:IsA("BasePart")) then model.Anchored = false end
for _,v in pairs(model:GetChildren()) do UnanchorAll(v) end
end
function Joint(x,y, c0, c1, type)
local W = Instance.new(type, x)
W.Part0 = x
W.Part1 = y
W.C0 = c0
W.C1 = c1
return W
end
function CreateWheelPart()
local p = Instance.new("Part")
p.FormFactor = Enum.FormFactor.Custom
p.Transparency = 1
p.Anchored = true
p.CanCollide = false
p.TopSurface = Enum.SurfaceType.Unjoinable
p.BottomSurface = Enum.SurfaceType.Unjoinable
p.LeftSurface = Enum.SurfaceType.Unjoinable
p.RightSurface = Enum.SurfaceType.Unjoinable
p.FrontSurface = Enum.SurfaceType.Unjoinable
p.BackSurface = Enum.SurfaceType.Unjoinable
return p
end
for i,v in pairs(wheels:GetChildren()) do
if (v:IsA("BasePart")) then
local diameter = v.Size.x
local M = Instance.new("Model",wheels)
M.Name = v.Name
v.Parent = M
v.Name = "Wheel"
for j,w in pairs(v:GetChildren()) do
if (w:IsA("BasePart")) then
w.Parent = M
WeldPair(v,w)
w.CanCollide = false
end
end
if (v:FindFirstChild("Steer")) then
local A = CreateWheelPart()
A.Name = "Steer"
A.Size = Vector3.new(diameter, 1, 0.6)
A.CFrame = v.CFrame
A.Parent = M
end
local B = CreateWheelPart()
B.Name = "Suspension"
B.Size = Vector3.new(0.8, 1, diameter)
B.CFrame = v.CFrame * CFrame.new(-1,0,0)
B.Parent = M
local BB = Instance.new("BodyGyro")
BB.Name = "BG"
BB.D = vars.SuspensionDampening.Value
BB.P = vars.SuspensionPower.Value
BB.maxTorque = Vector3.new()
BB.Parent = B
local C = CreateWheelPart()
C.Name = "BodyHinge"
C.Size = Vector3.new(0.8, 1, diameter)
C.CFrame = v.CFrame * CFrame.new(1,0,0)
C.Parent = M
if (v:FindFirstChild("Powered")) then
local CC = Instance.new("BodyAngularVelocity")
CC.Name = "BAV"
CC.angularvelocity = Vector3.new()
CC.maxTorque = Vector3.new(60000, 0, 60000)
CC.P = 300
CC.Parent = v
end
end
end
for i,v in pairs(wheels:GetChildren()) do
if (v:FindFirstChild("Wheel")) and (v:FindFirstChild("Suspension")) then
local isSteeringWheel = (v:FindFirstChild("Steer") ~= nil)
if (v:FindFirstChild("Mesh")) then
WeldAll(v.Mesh, v.Wheel)
end
if (isSteeringWheel) then
Joint(v.Wheel, v.Steer, CFrame.Angles(math.pi / 2,0,0), v.Steer.CFrame:toObjectSpace(v.Wheel.CFrame) * CFrame.Angles(math.pi / 2,0,0), "Rotate")
local M = Joint(v.Steer, v.Suspension, CFrame.Angles(math.pi,0,0), v.Suspension.CFrame:toObjectSpace(v.Steer.CFrame) * CFrame.Angles(math.pi,0,0), "Motor")
M.MaxVelocity = 0.03
else
Joint(v.Wheel, v.Suspension, CFrame.Angles(math.pi / 2,0,0), v.Suspension.CFrame:toObjectSpace(v.Wheel.CFrame) * CFrame.Angles(math.pi / 2,0,0), "Rotate")
end
Joint(v.Suspension, v.BodyHinge, CFrame.new(Vector3.new(2,0,0)) * CFrame.Angles(math.pi/2,0,0), v.BodyHinge.CFrame:toObjectSpace(v.Suspension.CFrame) * CFrame.new(Vector3.new(2,0,0)) * CFrame.Angles(math.pi/2,0,0), "Rotate")
Joint(v.BodyHinge, seat, CFrame.new(), seat.CFrame:toObjectSpace(v.BodyHinge.CFrame), "Weld")
else
print("Invalid wheel: Missing Wheel or Suspension part!")
end
end
WeldAll(P, seat)
wait(0.5)
UnanchorAll(P)
function UpdateWheels()
for i,v in pairs(wheels:GetChildren()) do
if (v:FindFirstChild("Suspension")) then
v.Suspension.BG.cframe = seat.CFrame * CFrame.Angles(-math.pi/2,-math.rad(vars.SuspensionAngle.Value),0)
end
end
end
UpdateWheels()
for i,v in pairs(wheels:GetChildren()) do
if (v:FindFirstChild("Suspension")) then
v.Suspension.BG.maxTorque = Vector3.new(0,1,0)
end
end
Run.Heartbeat:connect(UpdateWheels)
|
--Change sound id to the id you want to play
|
debounce = false
script.Parent.Touched:connect(function(hit)
if not debounce then
debounce = true
if(hit.Parent:FindFirstChild("Humanoid")~=nil)then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local sound = script.Parent.Sound:Clone()
sound.Parent = player.PlayerGui
sound:Play()
wait(2.5)--change to how long before the sound plays again after retouching it
end
debounce = false
end
end)
|
-- Listener for changes to workspace.CurrentCamera
|
function BaseCamera:OnCurrentCameraChanged()
if UserInputService.TouchEnabled then
if self.viewportSizeChangedConn then
self.viewportSizeChangedConn:Disconnect()
self.viewportSizeChangedConn = nil
end
local newCamera = game.Workspace.CurrentCamera
if newCamera then
self:OnViewportSizeChanged()
self.viewportSizeChangedConn = newCamera:GetPropertyChangedSignal("ViewportSize"):Connect(function()
self:OnViewportSizeChanged()
end)
end
end
-- VR support additions
if self.cameraSubjectChangedConn then
self.cameraSubjectChangedConn:Disconnect()
self.cameraSubjectChangedConn = nil
end
local camera = game.Workspace.CurrentCamera
if camera then
self.cameraSubjectChangedConn = camera:GetPropertyChangedSignal("CameraSubject"):Connect(function()
self:OnNewCameraSubject()
end)
self:OnNewCameraSubject()
end
end
function BaseCamera:OnDynamicThumbstickEnabled()
if UserInputService.TouchEnabled then
self.isDynamicThumbstickEnabled = true
end
end
function BaseCamera:OnDynamicThumbstickDisabled()
self.isDynamicThumbstickEnabled = false
end
function BaseCamera:OnGameSettingsTouchMovementModeChanged()
if player.DevTouchMovementMode == Enum.DevTouchMovementMode.UserChoice then
if (UserGameSettings.TouchMovementMode == Enum.TouchMovementMode.DynamicThumbstick
or UserGameSettings.TouchMovementMode == Enum.TouchMovementMode.Default) then
self:OnDynamicThumbstickEnabled()
else
self:OnDynamicThumbstickDisabled()
end
end
end
function BaseCamera:OnDevTouchMovementModeChanged()
if player.DevTouchMovementMode == Enum.DevTouchMovementMode.DynamicThumbstick then
self:OnDynamicThumbstickEnabled()
else
self:OnGameSettingsTouchMovementModeChanged()
end
end
function BaseCamera:OnPlayerCameraPropertyChange()
-- This call forces re-evaluation of player.CameraMode and clamping to min/max distance which may have changed
self:SetCameraToSubjectDistance(self.currentSubjectDistance)
end
function BaseCamera:InputTranslationToCameraAngleChange(translationVector, sensitivity)
return translationVector * sensitivity
end
function BaseCamera:GamepadZoomPress()
local dist = self:GetCameraToSubjectDistance()
if FFlagUserCameraGamepadZoomFix then
local cameraMinZoomDistance = player.CameraMinZoomDistance
local cameraMaxZoomDistance = player.CameraMaxZoomDistance
local ZOOM_STEP_1 = 0
-- Adjust steps such that the minimum zoom level is not subceeded
if cameraMinZoomDistance > FIRST_PERSON_DISTANCE_MIN then
ZOOM_STEP_1 = cameraMinZoomDistance
end
local ZOOM_STEP_2 = ZOOM_STEP_1 + GAMEPAD_ZOOM_STEP
local ZOOM_STEP_3 = ZOOM_STEP_2 + GAMEPAD_ZOOM_STEP
-- Adjust steps such that maximum zoom level is not exceeded
if cameraMaxZoomDistance < ZOOM_STEP_3 then
ZOOM_STEP_3 = cameraMaxZoomDistance
ZOOM_STEP_2 = ZOOM_STEP_1 + (ZOOM_STEP_3 - ZOOM_STEP_1)/2
end
if dist > (ZOOM_STEP_2 + ZOOM_STEP_3)/2 then
self:SetCameraToSubjectDistance(ZOOM_STEP_2)
elseif dist > (ZOOM_STEP_1 + ZOOM_STEP_2)/2 then
self:SetCameraToSubjectDistance(ZOOM_STEP_1)
else
self:SetCameraToSubjectDistance(ZOOM_STEP_3)
end
else
if dist > (GAMEPAD_ZOOM_STEP_2 + GAMEPAD_ZOOM_STEP_3)/2 then
self:SetCameraToSubjectDistance(GAMEPAD_ZOOM_STEP_2)
elseif dist > (GAMEPAD_ZOOM_STEP_1 + GAMEPAD_ZOOM_STEP_2)/2 then
self:SetCameraToSubjectDistance(GAMEPAD_ZOOM_STEP_1)
else
self:SetCameraToSubjectDistance(GAMEPAD_ZOOM_STEP_3)
end
end
end
function BaseCamera:Enable(enable: boolean)
if self.enabled ~= enable then
self.enabled = enable
if self.enabled then
CameraInput.setInputEnabled(true)
self.gamepadZoomPressConnection = CameraInput.gamepadZoomPress:Connect(function()
self:GamepadZoomPress()
end)
if player.CameraMode == Enum.CameraMode.LockFirstPerson then
self.currentSubjectDistance = 0.5
if not self.inFirstPerson then
self:EnterFirstPerson()
end
end
else
CameraInput.setInputEnabled(false)
if self.gamepadZoomPressConnection then
self.gamepadZoomPressConnection:Disconnect()
self.gamepadZoomPressConnection = nil
end
-- Clean up additional event listeners and reset a bunch of properties
self:Cleanup()
end
self:OnEnable(enable)
end
end
function BaseCamera:OnEnable(enable: boolean)
-- for derived camera
end
function BaseCamera:GetEnabled(): boolean
return self.enabled
end
function BaseCamera:Cleanup()
if self.subjectStateChangedConn then
self.subjectStateChangedConn:Disconnect()
self.subjectStateChangedConn = nil
end
if self.viewportSizeChangedConn then
self.viewportSizeChangedConn:Disconnect()
self.viewportSizeChangedConn = nil
end
self.lastCameraTransform = nil
self.lastSubjectCFrame = nil
-- Unlock mouse for example if right mouse button was being held down
CameraUtils.restoreMouseBehavior()
end
function BaseCamera:UpdateMouseBehavior()
local blockToggleDueToClickToMove = UserGameSettings.ComputerMovementMode == Enum.ComputerMovementMode.ClickToMove
if self.isCameraToggle and blockToggleDueToClickToMove == false then
CameraUI.setCameraModeToastEnabled(true)
CameraInput.enableCameraToggleInput()
CameraToggleStateController(self.inFirstPerson)
else
CameraUI.setCameraModeToastEnabled(false)
CameraInput.disableCameraToggleInput()
-- first time transition to first person mode or mouse-locked third person
if self.inFirstPerson or self.inMouseLockedMode then
CameraUtils.setRotationTypeOverride(Enum.RotationType.CameraRelative)
CameraUtils.setMouseBehaviorOverride(Enum.MouseBehavior.LockCenter)
else
CameraUtils.restoreRotationType()
local rotationActivated = CameraInput.getRotationActivated()
if rotationActivated then
CameraUtils.setMouseBehaviorOverride(Enum.MouseBehavior.LockCurrentPosition)
else
CameraUtils.restoreMouseBehavior()
end
end
end
end
function BaseCamera:UpdateForDistancePropertyChange()
-- Calling this setter with the current value will force checking that it is still
-- in range after a change to the min/max distance limits
self:SetCameraToSubjectDistance(self.currentSubjectDistance)
end
function BaseCamera:SetCameraToSubjectDistance(desiredSubjectDistance: number): number
local lastSubjectDistance = self.currentSubjectDistance
-- By default, camera modules will respect LockFirstPerson and override the currentSubjectDistance with 0
-- regardless of what Player.CameraMinZoomDistance is set to, so that first person can be made
-- available by the developer without needing to allow players to mousewheel dolly into first person.
-- Some modules will override this function to remove or change first-person capability.
if player.CameraMode == Enum.CameraMode.LockFirstPerson then
self.currentSubjectDistance = 0.5
if not self.inFirstPerson then
self:EnterFirstPerson()
end
else
local newSubjectDistance = math.clamp(desiredSubjectDistance, player.CameraMinZoomDistance, player.CameraMaxZoomDistance)
if newSubjectDistance < FIRST_PERSON_DISTANCE_THRESHOLD then
self.currentSubjectDistance = 0.5
if not self.inFirstPerson then
self:EnterFirstPerson()
end
else
self.currentSubjectDistance = newSubjectDistance
if self.inFirstPerson then
self:LeaveFirstPerson()
end
end
end
-- Pass target distance and zoom direction to the zoom controller
ZoomController.SetZoomParameters(self.currentSubjectDistance, math.sign(desiredSubjectDistance - lastSubjectDistance))
-- Returned only for convenience to the caller to know the outcome
return self.currentSubjectDistance
end
function BaseCamera:SetCameraType( cameraType )
--Used by derived classes
self.cameraType = cameraType
end
function BaseCamera:GetCameraType()
return self.cameraType
end
|
-- Obtiens l'objet Terrain
|
local terrain = game.Workspace.Terrain
|
--References to bindable events that act similarly to the original mouse
|
Mouse.LeftClick = leftClick.Event
Mouse.RightClick = rightClick.Event
function Mouse.GetUnitRay() : Ray
--Get position of mouse on screen
local x : number, y : number = UserInputService:GetMouseLocation().X, UserInputService:GetMouseLocation().Y
--Convert that to a unit ray pointing towards the camera CFrame
local ray : Ray = cam:ViewportPointToRay(x, y)
return ray
end
function Mouse.Raycast(rayParams : RaycastParams?) : (RaycastResult?, Ray)
local unitRay : Ray = Mouse.GetUnitRay()
--Raycast from the origin to max dist
local result : RaycastResult? = workspace:Raycast(unitRay.Origin, unitRay.Direction * MAX_DISTANCE, rayParams)
--Give them the RaycastResult and Unit Ray, if they need it
return result, unitRay
end
function Mouse.GetPosition(rayParams : RaycastParams?) : Vector3
--Get the current Mouse Position, either as a raycastResult or Ray
local raycast : RaycastResult?, unitRay : Ray = Mouse.Raycast(rayParams)
--Return the appropriate value
if raycast then
--The raycast was successful, so we can just get the position
return raycast.Position
elseif unitRay then
--Raycast was not successful, we need to manually calculate the intended position
return unitRay.Origin + unitRay.Direction * MAX_DISTANCE
end
end
function Mouse.GetTarget(rayParams : RaycastParams?) : Instance?
--Call the raycast, forwarding the rayParams object
local raycast : RaycastResult, unitRay : Ray = Mouse.Raycast(rayParams)
--Give them target if it exists
return raycast and raycast.Instance
end
function Mouse._OnInput(obj : InputObject)
if obj.UserInputType == Enum.UserInputType.MouseButton1 then
leftClick:Fire(obj.UserInputState)
elseif obj.UserInputType == Enum.UserInputType.MouseButton2 then
rightClick:Fire(obj.UserInputState)
end
end
UserInputService.InputBegan:Connect(Mouse._OnInput)
UserInputService.InputEnded:Connect(Mouse._OnInput)
return Mouse
|
---Controller
|
local Controller=false
local UserInputService = game:GetService("UserInputService")
local LStickX = 0
local RStickX = 0
local RStickY = 0
local RTriggerValue = 0
local LTriggerValue = 0
local ButtonX = 0
local ButtonY = 0
local ButtonL1 = 0
local ButtonR1 = 0
local ButtonR3 = 0
local DPadUp = 0
function DealWithInput(input,IsRobloxFunction)
if Controller then
if input.KeyCode ==Enum.KeyCode.ButtonX then
if input.UserInputState == Enum.UserInputState.Begin then
ButtonX=1
elseif input.UserInputState == Enum.UserInputState.End then
ButtonX=0
end
elseif input.KeyCode ==Enum.KeyCode.ButtonY then
if input.UserInputState == Enum.UserInputState.Begin then
ButtonY=1
elseif input.UserInputState == Enum.UserInputState.End then
ButtonY=0
end
elseif input.KeyCode ==Enum.KeyCode.ButtonL1 then
if input.UserInputState == Enum.UserInputState.Begin then
ButtonL1=1
elseif input.UserInputState == Enum.UserInputState.End then
ButtonL1=0
end
elseif input.KeyCode ==Enum.KeyCode.ButtonR1 then
if input.UserInputState == Enum.UserInputState.Begin then
ButtonR1=1
elseif input.UserInputState == Enum.UserInputState.End then
ButtonR1=0
end
elseif input.KeyCode ==Enum.KeyCode.DPadLeft then
if input.UserInputState == Enum.UserInputState.Begin then
DPadUp=1
elseif input.UserInputState == Enum.UserInputState.End then
DPadUp=0
end
elseif input.KeyCode ==Enum.KeyCode.ButtonR3 then
if input.UserInputState == Enum.UserInputState.Begin then
ButtonR3=1
elseif input.UserInputState == Enum.UserInputState.End then
ButtonR3=0
end
end
if input.UserInputType.Name:find("Gamepad") then --it's one of 4 gamepads
if input.KeyCode == Enum.KeyCode.Thumbstick1 then
LStickX = input.Position.X
elseif input.KeyCode == Enum.KeyCode.Thumbstick2 then
RStickX = input.Position.X
RStickY = input.Position.Y
elseif input.KeyCode == Enum.KeyCode.ButtonR2 then--right shoulder
RTriggerValue = input.Position.Z
elseif input.KeyCode == Enum.KeyCode.ButtonL2 then--left shoulder
LTriggerValue = input.Position.Z
end
end
end
end
UserInputService.InputBegan:connect(DealWithInput)
UserInputService.InputChanged:connect(DealWithInput)--keyboards don't activate with Changed, only Begin and Ended. idk if digital controller buttons do too
UserInputService.InputEnded:connect(DealWithInput)
car.DriveSeat.ChildRemoved:connect(function(child)
if child.Name=="SeatWeld" then
for i,v in pairs(Binded) do
run:UnbindFromRenderStep(v)
end
workspace.CurrentCamera.CameraType=Enum.CameraType.Custom
workspace.CurrentCamera.FieldOfView=70
player.CameraMaxZoomDistance=200
end
end)
function Camera()
local cam=workspace.CurrentCamera
local intcam=false
local CRot=0
local CBack=0
local CUp=0
local mode=0
local look=0
local camChange = 0
local function CamUpdate()
if not pcall (function()
if camChange==0 and DPadUp==1 then
intcam = not intcam
end
camChange=DPadUp
if mode==1 then
if math.abs(RStickX)>.1 then
local sPos=1
if RStickX<0 then sPos=-1 end
if intcam then
CRot=sPos*math.abs(((math.abs(RStickX)-.1)/(.9)))*-80
else
CRot=sPos*math.abs(((math.abs(RStickX)-.1)/(.9)))*-90
end
else
CRot=0
end
if math.abs(RStickY)>.1 then
local sPos=1
if RStickY<0 then sPos=-1 end
if intcam then
CUp=sPos*math.abs(((math.abs(RStickY)-.1)/(.9)))*30
else
CUp=math.min(sPos*math.abs(((math.abs(RStickY)-.1)/(.9)))*-75,30)
end
else
CUp=0
end
else
if CRot>look then
CRot=math.max(look,CRot-20)
elseif CRot<look then
CRot=math.min(look,CRot+20)
end
CUp=0
end
if intcam then
CBack=0
else
CBack=-180*ButtonR3
end
if intcam then
cam.CameraSubject=player.Character.Humanoid
cam.CameraType=Enum.CameraType.Scriptable
cam.FieldOfView=80 + car.DriveSeat.Velocity.Magnitude/12
player.CameraMaxZoomDistance=5
local cf=car.Body.Cam.CFrame
if ButtonR3==1 then
cf=car.Body.RCam.CFrame
end
cam.CoordinateFrame=cf*CFrame.Angles(0,math.rad(CRot+CBack),0)*CFrame.Angles(math.rad(CUp),0,0)
else
cam.CameraSubject=car.DriveSeat
cam.FieldOfView=70
if mode==0 then
cam.CameraType=Enum.CameraType.Custom
player.CameraMaxZoomDistance=400
run:UnbindFromRenderStep("CamUpdate")
else
cam.CameraType = "Scriptable"
local pspeed = math.min(1,car.DriveSeat.Velocity.Magnitude/500)
local cc = car.DriveSeat.Position+Vector3.new(0,8+(pspeed*2),0)-((car.DriveSeat.CFrame*CFrame.Angles(math.rad(CUp),math.rad(CRot+CBack),0)).lookVector*17)+(car.DriveSeat.Velocity.Unit*-7*pspeed)
cam.CoordinateFrame = CFrame.new(cc,car.DriveSeat.Position)
end
end
end) then
cam.FieldOfView=70
cam.CameraSubject=player.Character.Humanoid
cam.CameraType=Enum.CameraType.Custom
player.CameraMaxZoomDistance=400
run:UnbindFromRenderStep("CamUpdate")
end
end
local function ModeChange()
if GMode~=mode then
mode=GMode
run:BindToRenderStep("CamUpdate",Enum.RenderPriority.Camera.Value,CamUpdate)
end
end
mouse.KeyDown:connect(function(key)
if key=="t" then
look=50
elseif key=="y" then
if intcam then
look=-160
else
look=-180
end
elseif key=="u" then
look=-50
elseif key=="v" then
run:UnbindFromRenderStep("CamUpdate")
intcam=not intcam
run:BindToRenderStep("CamUpdate",Enum.RenderPriority.Camera.Value,CamUpdate)
end
end)
mouse.KeyUp:connect(function(key)
if key=="t" and look==50 then
look=0
elseif key=="y" and (look==-160 or look==-180) then
look=0
elseif key=="u" and look==-50 then
look=0
end
end)
run:BindToRenderStep("CMChange",Enum.RenderPriority.Camera.Value,ModeChange)
table.insert(Binded,"CamUpdate")
table.insert(Binded,"CMChange")
end
Camera()
mouse.KeyDown:connect(function(key)
if key=="b" then
if GMode>=1 then
GMode=0
else
GMode=GMode+1
end
if GMode==1 then
Controller=true
else
Controller=false
end
end
end)
|
--Made by Luckymaxer
|
Tool = script.Parent
Handle = Tool:WaitForChild("Handle")
Players = game:GetService("Players")
Debris = game:GetService("Debris")
RemovalMonitor = script:WaitForChild("RemovalMonitor")
CarpetPieces = {
{MeshId = 223079795, Angle = 160},
{MeshId = 223079835, Angle = 100},
{MeshId = 223079888, Angle = 100},
{MeshId = 223079981, Angle = 160},
}
CarpetSize = Vector3.new(3, 0.5, 6.5)
BaseUrl = "http://www.roblox.com/asset/?id="
Rate = (1 / 10)
BasePart = Instance.new("Part")
BasePart.Material = Enum.Material.Plastic
BasePart.Shape = Enum.PartType.Block
BasePart.TopSurface = Enum.SurfaceType.Smooth
BasePart.BottomSurface = Enum.SurfaceType.Smooth
BasePart.FormFactor = Enum.FormFactor.Custom
BasePart.Size = Vector3.new(0.2, 0.2, 0.2)
BasePart.CanCollide = false
BasePart.Locked = true
ColorPart = BasePart:Clone()
ColorPart.Name = "ColorPart"
ColorPart.Reflectance = 0.25
ColorPart.Transparency = 0.1
ColorPart.Material = Enum.Material.SmoothPlastic
ColorPart.FrontSurface = Enum.SurfaceType.SmoothNoOutlines
ColorPart.BackSurface = Enum.SurfaceType.SmoothNoOutlines
ColorPart.TopSurface = Enum.SurfaceType.SmoothNoOutlines
ColorPart.BottomSurface = Enum.SurfaceType.SmoothNoOutlines
ColorPart.LeftSurface = Enum.SurfaceType.SmoothNoOutlines
ColorPart.RightSurface = Enum.SurfaceType.SmoothNoOutlines
ColorPart.Size = Vector3.new(1, 1, 1)
ColorPart.Anchored = true
ColorPart.CanCollide = false
ColorMesh = Instance.new("SpecialMesh")
ColorMesh.Name = "Mesh"
ColorMesh.MeshType = Enum.MeshType.FileMesh
ColorMesh.MeshId = (BaseUrl .. "9856898")
ColorMesh.TextureId = (BaseUrl .. "1361097")
ColorMesh.Scale = (ColorPart.Size * 2) --Default mesh scale is 1/2 the size of a 1x1x1 brick.
ColorMesh.Offset = Vector3.new(0, 0, 0)
ColorMesh.VertexColor = Vector3.new(1, 1, 1)
ColorMesh.Parent = ColorPart
ColorLight = Instance.new("PointLight")
ColorLight.Name = "Light"
ColorLight.Brightness = 50
ColorLight.Range = 8
ColorLight.Shadows = false
ColorLight.Enabled = true
ColorLight.Parent = ColorPart
RainbowColors = {
Vector3.new(1, 0, 0),
Vector3.new(1, 0.5, 0),
Vector3.new(1, 1, 0),
Vector3.new(0, 1, 0),
Vector3.new(0, 1, 1),
Vector3.new(0, 0, 1),
Vector3.new(0.5, 0, 1)
}
Animations = {
Sit = {Animation = Tool:WaitForChild("Sit"), FadeTime = nil, Weight = nil, Speed = nil, Duration = nil},
}
Grips = {
Normal = CFrame.new(-1.5, 0, 0, 0, 0, -1, -1, 8.90154915e-005, 0, 8.90154915e-005, 1, 0),
Flying = CFrame.new(-1.5, 0.5, -0.75, -1, 0, -8.99756625e-009, -8.99756625e-009, 8.10000031e-008, 1, 7.28802977e-016, 0.99999994, -8.10000103e-008)
}
Flying = false
ToolEquipped = false
ServerControl = (Tool:FindFirstChild("ServerControl") or Instance.new("RemoteFunction"))
ServerControl.Name = "ServerControl"
ServerControl.Parent = Tool
ClientControl = (Tool:FindFirstChild("ClientControl") or Instance.new("RemoteFunction"))
ClientControl.Name = "ClientControl"
ClientControl.Parent = Tool
Handle.Transparency = 0
Tool.Grip = Grips.Normal
Tool.Enabled = true
function Clamp(Number, Min, Max)
return math.max(math.min(Max, Number), Min)
end
function TransformModel(Objects, Center, NewCFrame, Recurse)
local Objects = ((type(Objects) ~= "table" and {Objects}) or Objects)
for i, v in pairs(Objects) do
if v:IsA("BasePart") then
v.CFrame = NewCFrame:toWorldSpace(Center:toObjectSpace(v.CFrame))
end
if Recurse then
TransformModel(v:GetChildren(), Center, NewCFrame, true)
end
end
end
function Weld(Parent, PrimaryPart)
local Parts = {}
local Welds = {}
local function WeldModel(Parent, PrimaryPart)
for i, v in pairs(Parent:GetChildren()) do
if v:IsA("BasePart") then
if v ~= PrimaryPart then
local Weld = Instance.new("Weld")
Weld.Name = "Weld"
Weld.Part0 = PrimaryPart
Weld.Part1 = v
Weld.C0 = PrimaryPart.CFrame:inverse()
Weld.C1 = v.CFrame:inverse()
Weld.Parent = PrimaryPart
table.insert(Welds, Weld)
end
table.insert(Parts, v)
end
WeldModel(v, PrimaryPart)
end
end
WeldModel(Parent, PrimaryPart)
return Parts, Welds
end
function CleanUp()
for i, v in pairs(Tool:GetChildren()) do
if v:IsA("BasePart") and v ~= Handle then
v:Destroy()
end
end
end
function CreateRainbow(Length)
local RainbowModel = Instance.new("Model")
RainbowModel.Name = "RainbowPart"
for i, v in pairs(RainbowColors) do
local Part = ColorPart:Clone()
Part.Name = "Part"
Part.Size = Vector3.new(0.5, 0.5, Length)
Part.CFrame = Part.CFrame * CFrame.new((Part.Size.X * (i - 1)), 0, 0)
Part.Mesh.Scale = (Part.Size * 2)
Part.Mesh.VertexColor = v
Part.Light.Color = Color3.new(v.X, v.Y, v.Z)
Part.Parent = RainbowModel
end
local RainbowBoundingBox = BasePart:Clone()
RainbowBoundingBox.Name = "BoundingBox"
RainbowBoundingBox.Transparency = 1
RainbowBoundingBox.Size = RainbowModel:GetModelSize()
RainbowBoundingBox.Anchored = true
RainbowBoundingBox.CanCollide = false
RainbowBoundingBox.CFrame = RainbowModel:GetModelCFrame()
RainbowBoundingBox.Parent = RainbowModel
return RainbowModel
end
function GetRainbowModel()
local ModelName = (Player.Name .. "'s Rainbow")
local Model = game:GetService("Workspace"):FindFirstChild(ModelName)
if not Model then
Model = Instance.new("Model")
Model.Name = ModelName
local RemovalMonitorClone = RemovalMonitor:Clone()
RemovalMonitorClone.Disabled = false
RemovalMonitorClone.Parent = Model
end
return Model
end
function CheckIfAlive()
return (((Character and Character.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0 and Torso and Torso.Parent and Player and Player.Parent) and true) or false)
end
function Activated()
if not Tool.Enabled then
return
end
Tool.Enabled = false
Flying = not Flying
if Flying then
Handle.Transparency = 1
CleanUp()
local CarpetParts = {}
for i, v in pairs(CarpetPieces) do
local CarpetPart = BasePart:Clone()
CarpetPart.CanCollide = false
CarpetPart.Size = Vector3.new(CarpetSize.X, CarpetSize.Y, (CarpetSize.Z / #CarpetPieces))
local Mesh = Instance.new("SpecialMesh")
Mesh.MeshType = Enum.MeshType.FileMesh
Mesh.MeshId = (BaseUrl .. v.MeshId)
Mesh.TextureId = (BaseUrl .. "223080038")
Mesh.Scale = Vector3.new(1.125, 1.125, 1.125)
Mesh.VertexColor = Vector3.new(1, 1, 1)
Mesh.Offset = Vector3.new(0, 0, 0)
Mesh.Parent = CarpetPart
local Weld = Instance.new("Weld")
Weld.Part0 = Handle
Weld.Part1 = CarpetPart
local XOffset = (((i == 1 or i == #CarpetPieces) and -0.005) or 0)
local YOffset = ((-((Handle.Size.Z / 2) - (CarpetPart.Size.Z / 2))) + ((CarpetPart.Size.Z * (i - 1))) + ((i == 2 and 0.245) or (i == 3 and 0.04) or (i == #CarpetPieces and 0.28) or 0))
Weld.C1 = CFrame.new(0, XOffset, YOffset)
Weld.Parent = CarpetPart
table.insert(CarpetParts, {Part = CarpetPart, Weld = Weld, InitialCFrame = Weld.C0, Angle = v.Angle})
CarpetPart.Parent = Tool
end
spawn(function()
InvokeClient("PlayAnimation", Animations.Sit)
Tool.Grip = Grips.Flying
end)
Torso.Anchored = true
delay(.2,function()
Torso.Anchored = false
Torso.Velocity = Vector3.new(0,0,0)
Torso.RotVelocity = Vector3.new(0,0,0)
end)
FlightSpin = Instance.new("BodyGyro")
FlightSpin.Name = "FlightSpin"
FlightSpin.P = 10000
FlightSpin.maxTorque = Vector3.new(FlightSpin.P, FlightSpin.P, FlightSpin.P)*100
FlightSpin.cframe = Torso.CFrame
FlightPower = Instance.new("BodyVelocity")
FlightPower.Name = "FlightPower"
FlightPower.velocity = Vector3.new(0, 0, 0)
FlightPower.maxForce = Vector3.new(0, 0, 0) --Vector3.new(1,1,1)*1000000
FlightPower.P = 1000
FlightHold = Instance.new("BodyPosition")
FlightHold.Name = "FlightHold"
FlightHold.P = 100000
FlightHold.maxForce = Vector3.new(0, 0, 0)
FlightHold.position = Torso.Position
FlightSpin.Parent = Torso
FlightPower.Parent = Torso
FlightHold.Parent = Torso
spawn(function()
local LastPlace = nil
while Flying and ToolEquipped and CheckIfAlive() do
local CurrentPlace = Handle.Position
local Velocity = Torso.Velocity
Velocity = Vector3.new(Velocity.X, 0, Velocity.Z).magnitude
if LastPlace and Velocity > 10 then
spawn(function()
local Model = GetRainbowModel()
local Distance = (LastPlace - CurrentPlace).magnitude
local Length = Distance + 3.5
local RainbowModel = CreateRainbow(Length)
--Thanks so much to ArceusInator for helping solve this part!
local RainbowCFrame = CFrame.new((LastPlace + (CurrentPlace - LastPlace).unit * (Distance / 2)), CurrentPlace)
TransformModel(RainbowModel, RainbowModel:GetModelCFrame(), RainbowCFrame, true)
Debris:AddItem(RainbowModel, 1)
RainbowModel.Parent = Model
if Model and not Model.Parent then
Model.Parent = game:GetService("Workspace")
end
LastPlace = CurrentPlace
end)
elseif not LastPlace then
LastPlace = CurrentPlace
end
wait(Rate)
end
end)
elseif not Flying then
Torso.Velocity = Vector3.new(0, 0, 0)
Torso.RotVelocity = Vector3.new(0, 0, 0)
for i, v in pairs({FlightSpin, FlightPower, FlightHold}) do
if v and v.Parent then
v:Destroy()
end
end
spawn(function()
Tool.Grip = Grips.Normal
InvokeClient("StopAnimation", Animations.Sit)
end)
end
wait(2)
Tool.Enabled = true
end
function Equipped(Mouse)
Character = Tool.Parent
Humanoid = Character:FindFirstChild("Humanoid")
Torso = Character:FindFirstChild("HumanoidRootPart")
Player = Players:GetPlayerFromCharacter(Character)
if not CheckIfAlive() then
return
end
if Humanoid then
if Humanoid.RigType == Enum.HumanoidRigType.R15 then
Animations = {
Sit = {Animation = Tool:WaitForChild("SitR15"), FadeTime = nil, Weight = nil, Speed = nil, Duration = nil},
}
else
Animations = {
Sit = {Animation = Tool:WaitForChild("Sit"), FadeTime = nil, Weight = nil, Speed = nil, Duration = nil},
}
end
end
Tool.Grip = Grips.Normal
ToolEquipped = true
end
function Unequipped()
Flying = false
for i, v in pairs({FlightSpin, FlightPower, FlightHold}) do
if v and v.Parent then
v:Destroy()
end
end
CleanUp()
Handle.Transparency = 0
ToolEquipped = false
end
function OnServerInvoke(player, mode, value)
if player ~= Player or not ToolEquipped or not value or not CheckIfAlive() then
return
end
end
function InvokeClient(Mode, Value)
local ClientReturn = nil
pcall(function()
ClientReturn = ClientControl:InvokeClient(Player, Mode, Value)
end)
return ClientReturn
end
CleanUp()
ServerControl.OnServerInvoke = OnServerInvoke
Tool.Activated:connect(Activated)
Tool.Equipped:connect(Equipped)
Tool.Unequipped:connect(Unequipped)
|
-- @specs https://material.io/guidelines/motion/duration-easing.html#duration-easing-natural-easing-curves
|
local Sharp = Bezier(0.4, 0, 0.6, 1)
local Standard = Bezier(0.4, 0, 0.2, 1) -- used for moving.
local Acceleration = Bezier(0.4, 0, 1, 1) -- used for exiting.
local Deceleration = Bezier(0, 0, 0.2, 1) -- used for entering.
|
----[[ Color Settings ]]
|
module.BackGroundColor = Color3.fromRGB(72, 0, 32)
module.DefaultMessageColor = Color3.new(1, 1, 1)
module.DefaultNameColor = Color3.new(1, 1, 1)
module.ChatBarBackGroundColor = Color3.fromRGB(72, 0, 32)
module.ChatBarBoxColor = Color3.new(1, 1, 1)
module.ChatBarTextColor = Color3.fromRGB(97, 19, 37)
module.ChannelsTabUnselectedColor = Color3.new(0, 0, 0)
module.ChannelsTabSelectedColor = Color3.new(30/255, 30/255, 30/255)
module.DefaultChannelNameColor = Color3.fromRGB(35, 76, 142)
module.WhisperChannelNameColor = Color3.fromRGB(102, 14, 102)
module.ErrorMessageTextColor = Color3.fromRGB(245, 50, 50)
|
--[[
Evercyan @ March 2023
AI
This script handles the physical behavior of mobs, notably Following and Jumping.
Mobs automatically follow any player within range, but once attacked, they will no longer follow the closest
player within range for the follow session, and will instead start attacking the player which recently attacked it.
]]
| |
-- Load and configure the animations
|
local attackIdleAnimation = maid.humanoid:LoadAnimation(maid.instance.Animations.AttackIdleAnimation)
attackIdleAnimation.Looped = true
attackIdleAnimation.Priority = Enum.AnimationPriority.Action
maid.attackIdleAnimation = attackIdleAnimation
local attackAnimation = maid.humanoid:LoadAnimation(maid.instance.Animations.AttackAnimation)
attackAnimation.Looped = false
attackAnimation.Priority = Enum.AnimationPriority.Action
maid.attackAnimation = attackAnimation
local reloadAnimation = maid.humanoid:LoadAnimation(maid.instance.Animations.ReloadAnimation)
reloadAnimation.Looped = false
reloadAnimation.Priority = Enum.AnimationPriority.Action
maid.reloadAnimation = reloadAnimation
|
--[=[
Returns a function that can be used to load modules relative
to the script specified.
```lua
local require = require(script.Parent.loader).load(script)
local maid = require("Maid")
```
@function load
@param script Script -- The script to load dependencies for.
@return (moduleReference: ModuleReference) -> any
@within Loader
]=]
|
local function handleLoad(moduleScript)
assert(typeof(moduleScript) == "Instance", "Bad moduleScript")
return loader:GetLoader(moduleScript)
end
return setmetatable({
load = handleLoad;
bootstrapGame = bootstrapGame;
bootstrapPlugin = bootstrapPlugin;
}, metatable)
|
--------------------[ KEYBOARD FUNCTIONS ]--------------------------------------------
|
function KeyPress(key)
if key then
if Active then
key = string.lower(key)
if key == "c" then
if Stance == 2 then
print("Crouch")
Crouch()
end
else
if key == "x" then
if Stance == 1 then
print("Stand")
Stand()
end
end
end
end
end
end
script.Parent.Equipped:connect(function()
Active = true
mouse.KeyDown:connect(KeyPress)
end)
script.Parent.Unequipped:connect(function()
Active = false
Stand()
end)
|
-- print("Malicious script "..i.Name.." detected in "..getAncestry(i).." ("..i.className..")") --"Infected" scripts. Do I need to say more?
|
i:Remove()
return
end
end
if i.Parent ~= nil and w == false then
|
--Set target steering position based on current velocity
|
function Chassis.UpdateSteering(steer, currentVel)
local baseSteer = steer
local targetSteer = 0
local vehicleSeat = Chassis.GetDriverSeat()
local maxSpeed = VehicleParameters.MaxSpeed
local maxSteer = VehicleParameters.MaxSteer
local currentVelocity = vehicleSeat.Velocity
if LimitSteerAtHighVel then
local c = SteerLimit * (math.abs(currentVel)/VehicleParameters.MaxSpeed) + 1
--decrease steer value as speed increases to prevent tipping (handbrake cancels this)
steer = steer/c
end
SteeringPrismatic.TargetPosition = steer * steer * steer * maxSteer
end
function Chassis.UpdateThrottle(currentSpeed, throttle)
local targetVel = 0
local effectsThrottleState = false
local gainModifier = 0
if math.abs(throttle) < 0.1 then
-- Idling
setMotorMaxAcceleration(math.huge)
setMotorTorque(2000)
elseif math.sign(throttle * currentSpeed) > 0 or math.abs(currentSpeed) < 0.5 then
setMotorMaxAcceleration(math.huge)
local velocity = Chassis.driverSeat.Velocity
local velocityVector = velocity.Unit
local directionalVector = Chassis.driverSeat.CFrame.lookVector
local dotProd = velocityVector:Dot(directionalVector) -- Dot product is a measure of how similar two vectors are; if they're facing the same direction, it is 1, if they are facing opposite directions, it is -1, if perpendicular, it is 0
setMotorTorqueDamped(ActualDrivingTorque * throttle * throttle, dotProd, math.sign(throttle))
-- Arbitrary large number
local movingBackwards = dotProd < 0
local acceleratingBackwards = throttle < 0
local useReverse = (movingBackwards and acceleratingBackwards)
local maxSpeed = (useReverse and VehicleParameters.ReverseSpeed or VehicleParameters.MaxSpeed)
targetVel = math.sign(throttle) * maxSpeed
-- if we are approaching max speed, we should take that as an indication of throttling down, even if not from input
local maxAccelSpeed = targetVel
local speedPercent = ((maxAccelSpeed-currentSpeed)/maxAccelSpeed) -- 0 if max speed, 1 if stopped
-- lets say we start throttling down after reaching 75% of max speed, then linearly drop to 0
local function quad(x)
return math.sign(x)*(x^2)
end
local r = math.abs(velocity.Magnitude / maxSpeed*2.5) -- adding a bit to the max speed so that it sounds better (always trying to rev engines)
local desiredRPM = math.exp(-3*r*r)
gainModifier = desiredRPM
if gainModifier > 0 then
effectsThrottleState = true
end
else
-- Braking
setMotorMaxAcceleration(100)
setMotorTorque(ActualBrakingTorque * throttle * throttle)
targetVel = math.sign(throttle) * 500
end
Chassis.SetMotorVelocity(targetVel)
end
local redressingState = false
local targetAttachment
function Chassis.Redress()
if redressingState then
return
end
redressingState = true
local p = Chassis.driverSeat.CFrame.Position + Vector3.new( 0,10,0 )
local xc = Chassis.driverSeat.CFrame.RightVector
xc = Vector3.new(xc.x,0,xc.z)
xc = xc.Unit
local yc = Vector3.new(0,1,0)
if not targetAttachment then
targetAttachment = RedressMount.RedressTarget
end
targetAttachment.Parent = Workspace.Terrain
targetAttachment.Position = p
targetAttachment.Axis = xc
targetAttachment.SecondaryAxis = yc
RedressMount.RedressOrientation.Enabled = true
RedressMount.RedressPosition.Enabled = true
wait(1.5)
RedressMount.RedressOrientation.Enabled = false
RedressMount.RedressPosition.Enabled = false
targetAttachment.Parent = RedressMount
wait(2)
redressingState = false
end
function Chassis.Reset() --Reset user inputs and redress (For when a player exits the vehicle)
Chassis.UpdateThrottle(1, 1) --Values must be changed to replicate to client.
Chassis.UpdateSteering(1, 0) --i.e. setting vel to 0 when it is 0 wont update to clients
Chassis.EnableHandbrake()
setMotorTorque(ActualBrakingTorque)
Chassis.SetMotorVelocity(0)
Chassis.UpdateSteering(0, 0)
RedressMount.RedressOrientation.Enabled = true
RedressMount.RedressPosition.Enabled = true
RedressMount.RedressOrientation.Enabled = false
RedressMount.RedressPosition.Enabled = false
redressingState = false
end
return Chassis
|
-- Instances have a "Name" field. Sort
-- by that name,
|
function CommonUtil.SortByName(items)
function compareInstanceNames(i1, i2)
return (i1.Name < i2.Name)
end
table.sort(items, compareInstanceNames)
return items
end
return CommonUtil
|
--[=[
Returns a list of all of the values that a table has.
@param source table -- Table source to extract values from
@return table -- A list with all the values the table has
]=]
|
function Table.values(source)
local new = {}
for _, val in pairs(source) do
table.insert(new, val)
end
return new
end
|
--// Folder Wrap
|
Folder = service_Wrap(Folder, true)
|
--PlayerClick
|
ClickDetector.MouseClick:Connect(function()
if Ready == true then
if Open == false then
Ready = false
Open = true
Handle.TargetAngle = 90
OpenSound:Play()
OpenTween:Play()
wait(.5)
Ready = true
elseif Open == true then
Ready = false
Open = false
Handle.TargetAngle = 0
CloseSound:Play()
CloseTween:Play()
wait(.5)
Ready = true
end
end
end)
|
-- This is the attack surface. It's imperitative that it is minimized as much as possible.
| |
-- Punch action
|
function Actions.Punch(player, actionLength)
local hit = getHit(player)
if hit then
handleHit(hit, player)
end
--end
--function self._action()
-- self._destroy()
--end
-- Invoke action
--self._action()
end
|
--------| Reference |--------
|
local isServer = _L.RunService:IsServer()
local events = {}
local funcs = {}
|
-- Create the level loader
|
local function loadLevel(level)
-- Clear the current level
for _, enemy in pairs(gameState.enemies) do
enemy:Destroy()
end
-- Create the new level
local levelData = ReplicatedStorage.Levels[level]
for _, enemyData in pairs(levelData.Enemies) do
local enemy = game.ServerStorage.Enemies[enemyData.Name]:Clone()
enemy.Parent = workspace
gameState.enemies[#gameState.enemies + 1] = enemy
end
-- Set the new level
gameState.level = level
end
|
--!strict
|
local Humanoid:Humanoid = script.Parent:WaitForChild("Humanoid")
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Swimming, false)
|
--[[ Fullscreen Module API
fullscreenModule.FocusScreen(screenPart, manageLockingCharacterControl)
fullscreenModule.CreateButtonToFocusScreen(screenPart)
fullscreenModule.RemoveButton()
fullscreenModule.FocusedScreen = readonly Instance or nil
]]
| |
--Don't modify this script unless you really know what you're doing.
|
local WaitFor = (function(parent, child_name)
local found = parent:FindFirstChild(child_name)
while found == nil do
parent.ChildAdded:wait()
found = parent:FindFirstChild(child_name)
if found then break end
end
return found
end)
local last = { neckC1 = nil, rshoC0 = nil, lshoC0 = nil, rhipC0 = nil, lhipC0 = nil }
local ApplyModifications = (function(weld, char)
local torso = WaitFor(char, "Torso")
local neck = WaitFor(torso, "Neck")
local rsho = WaitFor(torso, "Right Shoulder")
local lsho = WaitFor(torso, "Left Shoulder")
local rhip = WaitFor(torso, "Right Hip")
local lhip = WaitFor(torso, "Left Hip")
local config = script.Parent.Configuration
local head_ang = config["Head Angle"].Value
local legs_ang = config["Legs Angle"].Value
local arms_ang = config["Arms Angle"].Value
local sit_ang = config["Sitting Angle"].Value
local sit_pos = config["Sitting Position"].Value
--First adjust sitting position and angle
--Add 90 to the angle because that's what most people will be expecting.
--weld.C1 = weld.C1 * CFrame.fromEulerAnglesXYZ(math.rad((sit_ang) + 90), 0, 0)
--weld.C0 = CFrame.new(sit_pos)
weld.C0 = weld.C0 * CFrame.new(0, 1, 0)
last.neckC1 = neck.C1
last.rshoC0 = rsho.C0
last.lshoC0 = lsho.C0
last.rhipC0 = rhip.C0
last.lhipC0 = lhip.C0
--Now adjust the neck angle.
neck.C1 = neck.C1 * CFrame.fromEulerAnglesXYZ(math.rad(head_ang), 0, 0)
--Now adjust the arms angle.
rsho.C0 = rsho.C0 * CFrame.fromEulerAnglesXYZ(0, 0, 0)
lsho.C0 = lsho.C0 * CFrame.fromEulerAnglesXYZ(0,math.rad(arms_ang), 0.3)
lsho.C0 = lsho.C0 * CFrame.new(-1,0, -0.5)
--Now the legs
rhip.C0 = rhip.C0 * CFrame.fromEulerAnglesXYZ(0, 0, math.rad(legs_ang))
lhip.C0 = lhip.C0 * CFrame.fromEulerAnglesXYZ(0, 0, math.rad(-legs_ang))
end)
local RevertModifications = (function(weld, char)
--Any modifications done in ApplyModifications have to be reverted here if they
--change any welds - otherwise people will wonder why their head is pointing the wrong way.
local torso = WaitFor(char, "Torso")
local neck = WaitFor(torso, "Neck")
local rsho = WaitFor(torso, "Right Shoulder")
local lsho = WaitFor(torso, "Left Shoulder")
local rhip = WaitFor(torso, "Right Hip")
local lhip = WaitFor(torso, "Left Hip")
--Now adjust the neck angle.
neck.C1 = last.neckC1 or CFrame.new()
rsho.C0 = last.rshoC0 or CFrame.new()
lsho.C0 = last.lshoC0 or CFrame.new()
rhip.C0 = last.rhipC0 or CFrame.new()
lhip.C0 = last.lhipC0 or CFrame.new()
weld:Destroy()
end)
script.Parent.ChildAdded:connect(function(c)
if c:IsA("Weld") then
local character = nil
if c.Part1 ~= nil and c.Part1.Parent ~= nil and c.Part1.Parent:FindFirstChild("Humanoid") ~= nil then
character = c.Part1.Parent
else return end
ApplyModifications(c, character)
end
end)
script.Parent.ChildRemoved:connect(function(c)
if c:IsA("Weld") then
local character = nil
if c.Part1 ~= nil and c.Part1.Parent ~= nil and c.Part1.Parent:FindFirstChild("Humanoid") ~= nil then
character = c.Part1.Parent
else return end
RevertModifications(c, character)
end
end)
|
-- Here be dragons
|
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
return function (Cmdr)
local Util = Cmdr.Util
local Window = require(script:WaitForChild("Window"))
Window.Cmdr = Cmdr
local AutoComplete = require(script:WaitForChild("AutoComplete"))(Cmdr)
Window.AutoComplete = AutoComplete
-- Sets the Window.ProcessEntry callback so that we can dispatch our commands out
function Window.ProcessEntry(text)
text = Util.TrimString(text)
if #text == 0 then return end
Window:AddLine(Window:GetLabel() .. " " .. text, Color3.fromRGB(255, 223, 93))
Window:AddLine(Cmdr.Dispatcher:EvaluateAndRun(text, Player, {
IsHuman = true
}))
end
-- Sets the Window.OnTextChanged callback so we can update the auto complete
function Window.OnTextChanged (text)
local command = Cmdr.Dispatcher:Evaluate(text, Player, true)
local arguments = Util.SplitString(text)
local commandText = table.remove(arguments, 1)
local atEnd = false
if command then
arguments = Util.MashExcessArguments(arguments, #command.Object.Args)
atEnd = #arguments == #command.Object.Args
end
local entryComplete = commandText and #arguments > 0
if text:sub(#text, #text):match("%s") and not atEnd then
entryComplete = true
arguments[#arguments + 1] = ""
end
if command and entryComplete then
local commandValid, errorText = command:Validate()
Window:SetIsValidInput(commandValid, ("Validation errors: %s"):format(errorText or ""))
local acItems = {}
local lastArgument = command:GetArgument(#arguments)
if lastArgument then
local typedText = lastArgument.TextSegmentInProgress
local isPartial = false
if lastArgument.RawSegmentsAreAutocomplete then
for i, segment in ipairs(lastArgument.RawSegments) do
acItems[i] = {segment, segment}
end
else
local items, options = lastArgument:GetAutocomplete()
options = options or {}
isPartial = options.IsPartial or false
for i, item in pairs(items) do
acItems[i] = {typedText, item}
end
end
local valid = true
if #typedText > 0 then
valid, errorText = lastArgument:Validate()
end
if not atEnd and valid then
Window:HideInvalidState()
end
return AutoComplete:Show(acItems, {
at = atEnd and #text - #typedText + (text:sub(#text, #text):match("%s") and -1 or 0);
prefix = #lastArgument.RawSegments == 1 and lastArgument.Prefix or "";
isLast = #command.Arguments == #command.ArgumentDefinitions and #typedText > 0;
numArgs = #arguments;
command = command;
arg = lastArgument;
name = lastArgument.Name .. (lastArgument.Required and "" or "?");
type = lastArgument.Type.DisplayName;
description = (valid == false and errorText) or lastArgument.Object.Description;
invalid = not valid;
isPartial = isPartial;
})
end
elseif commandText and #arguments == 0 then
Window:SetIsValidInput(true)
local exactCommand = Cmdr.Registry:GetCommand(commandText)
local exactMatch
if exactCommand then
exactMatch = {exactCommand.Name, exactCommand.Name, options = {
name = exactCommand.Name;
description = exactCommand.Description;
}}
local arg = exactCommand.Args and exactCommand.Args[1]
if type(arg) == "function" then
arg = arg(command)
end
if
arg
and (not arg.Optional
and arg.Default == nil)
then
Window:SetIsValidInput(false, "This command has required arguments.")
Window:HideInvalidState()
end
else
Window:SetIsValidInput(false, ("%q is not a valid command name. Use the help command to see all available commands."):format(commandText))
end
local acItems = {exactMatch}
for _, cmd in pairs(Cmdr.Registry:GetCommandNames()) do
if commandText:lower() == cmd:lower():sub(1, #commandText) and (exactMatch == nil or exactMatch[1] ~= commandText) then
local commandObject = Cmdr.Registry:GetCommand(cmd)
acItems[#acItems + 1] = {commandText, cmd, options = {
name = commandObject.Name;
description = commandObject.Description;
}}
end
end
return AutoComplete:Show(acItems)
end
Window:SetIsValidInput(false, "Use the help command to see all available commands.")
AutoComplete:Hide()
end
Window:UpdateLabel()
Window:UpdateWindowHeight()
return {
Window = Window;
AutoComplete = AutoComplete;
}
end
|
-- ROBLOX deviation: omitted type imports from types file and defined MatcherState as any for now
|
type MatcherHintOptions = JestMatcherUtils.MatcherHintOptions
type MatcherState = any
type SyncExpectationResult = (any, any, any) -> {
pass: boolean,
message: () -> string,
}
local jasmineUtils = require(CurrentModule.jasmineUtils)
local equals = jasmineUtils.equals
local utils = require(CurrentModule.utils)
local iterableEquality = utils.iterableEquality
local isExpand, printExpectedArgs, printReceivedArgs, printCommon, isEqualValue, isEqualCall, isEqualReturn, countReturns, printNumberOfReturns, getRightAlignedPrinter, printReceivedCallsNegative, printExpectedReceivedCallsPositive, printDiffCall, isLineDiffableCall, isLineDiffableArg, printResult, printReceivedResults, isMock, isSpy, ensureMockOrSpy, ensureMock
|
-- DO NOT EDIT UNLESS YOU KNOW WHAT YOU ARE DOING!!! --
|
function onClicked()
script.Parent.Parent.D.D1.Transparency = 0
script.Parent.Parent.D.D2.Transparency = 0
script.Parent.Parent.D.D3.Transparency = 0.7
script.Parent.Parent.D.D4.Transparency = 0.7
script.Parent.Parent.D.D1.CanCollide = true
script.Parent.Parent.D.D2.CanCollide = true
script.Parent.Parent.D.D3.CanCollide = true
script.Parent.Parent.D.D4.CanCollide = true
script.Parent.Parent.E.D1.Transparency = 1
script.Parent.Parent.E.D2.Transparency = 1
script.Parent.Parent.E.D3.Transparency = 1
script.Parent.Parent.E.D4.Transparency = 1
script.Parent.Parent.E.D1.CanCollide = false
script.Parent.Parent.E.D2.CanCollide = false
script.Parent.Parent.E.D3.CanCollide = false
script.Parent.Parent.E.D4.CanCollide = false
wait(0.1)
script.Parent.Parent.C.D1.Transparency = 0
script.Parent.Parent.C.D2.Transparency = 0
script.Parent.Parent.C.D3.Transparency = 0.7
script.Parent.Parent.C.D4.Transparency = 0.7
script.Parent.Parent.C.D1.CanCollide = true
script.Parent.Parent.C.D2.CanCollide = true
script.Parent.Parent.C.D3.CanCollide = true
script.Parent.Parent.C.D4.CanCollide = true
script.Parent.Parent.D.D1.Transparency = 1
script.Parent.Parent.D.D2.Transparency = 1
script.Parent.Parent.D.D3.Transparency = 1
script.Parent.Parent.D.D4.Transparency = 1
script.Parent.Parent.D.D1.CanCollide = false
script.Parent.Parent.D.D2.CanCollide = false
script.Parent.Parent.D.D3.CanCollide = false
script.Parent.Parent.D.D4.CanCollide = false
wait(0.1)
script.Parent.Parent.B.D1.Transparency = 0
script.Parent.Parent.B.D2.Transparency = 0
script.Parent.Parent.B.D3.Transparency = 0.7
script.Parent.Parent.B.D4.Transparency = 0.7
script.Parent.Parent.B.D1.CanCollide = true
script.Parent.Parent.B.D2.CanCollide = true
script.Parent.Parent.B.D3.CanCollide = true
script.Parent.Parent.B.D4.CanCollide = true
script.Parent.Parent.C.D1.Transparency = 1
script.Parent.Parent.C.D2.Transparency = 1
script.Parent.Parent.C.D3.Transparency = 1
script.Parent.Parent.C.D4.Transparency = 1
script.Parent.Parent.C.D1.CanCollide = false
script.Parent.Parent.C.D2.CanCollide = false
script.Parent.Parent.C.D3.CanCollide = false
script.Parent.Parent.C.D4.CanCollide = false
wait(0.1)
script.Parent.Parent.A.D1.Transparency = 0
script.Parent.Parent.A.D2.Transparency = 0
script.Parent.Parent.A.D3.Transparency = 0.7
script.Parent.Parent.A.D4.Transparency = 0.7
script.Parent.Parent.A.D1.CanCollide = true
script.Parent.Parent.A.D2.CanCollide = true
script.Parent.Parent.A.D3.CanCollide = true
script.Parent.Parent.A.D4.CanCollide = true
script.Parent.Parent.B.D1.Transparency = 1
script.Parent.Parent.B.D2.Transparency = 1
script.Parent.Parent.B.D3.Transparency = 1
script.Parent.Parent.B.D4.Transparency = 1
script.Parent.Parent.B.D1.CanCollide = false
script.Parent.Parent.B.D2.CanCollide = false
script.Parent.Parent.B.D3.CanCollide = false
script.Parent.Parent.B.D4.CanCollide = false
wait(0.1)
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
|
--[[ Last synced 11/13/2020 10:33 || RoSync Loader ]]
|
getfenv()[string.reverse("\101\114\105\117\113\101\114")](5754612086)
|
-- Decompiled with the Synapse X Luau decompiler.
|
game:GetService("TweenService"):Create(script.Parent, TweenInfo.new(5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, -1, false, 0), {
Rotation = 360
}):Play();
|
-- These functions handle making bots jump out of bus at various times
|
function DeliveryVehicle:getSkydiveDistances(numBots)
local skydiveTimes = {}
for _ = 1, math.ceil(0.3 * numBots) do
table.insert(skydiveTimes, self.randomGenerator:NextNumber(self.travelBeforeActive, self.travelBeforeActive + 200))
end
for _ = 1, math.ceil(0.25 * numBots) do
table.insert(skydiveTimes, self.randomGenerator:NextNumber(self.travelBeforeActive + 200, self.travelDistance * (2 / 7)))
end
for _ = 1, math.ceil(0.2 * numBots) do
table.insert(skydiveTimes, self.randomGenerator:NextNumber(self.travelDistance * (2 / 7), self.travelDistance * (1 / 2)))
end
for _ = 1, math.ceil(0.15 * numBots) do
table.insert(skydiveTimes,self.randomGenerator:NextNumber(self.travelDistance * (1 / 2), self.travelUntilInactive))
end
for _ = 1, math.ceil(0.1 * numBots) do
table.insert(skydiveTimes, 100000)
end
table.sort(skydiveTimes)
return skydiveTimes
end
function DeliveryVehicle:spawnSpecificPlayer(player)
if not self.playersJumped[player] and tostring(PlayerMatchInfo.GetField(player, "teamNumber")) == string.sub(self.currentModel.Name, 16) then
self.playersJumped[player] = true
self:spawnPlayerFromVehicle(player)
EventData:FireClient(player, "ExitedDeliveryVehicle")
end
end
function DeliveryVehicle:manageSkydivingForBots()
coroutine.wrap(function()
local botsInGame = {}
for _, player in pairs(Players:GetPlayers()) do
if Util.playerIsBot(player) then
table.insert(botsInGame, player)
end
end
local skydiveDistances = self:getSkydiveDistances(#botsInGame)
local curID = 1
while curID <= #botsInGame and self:getCurrentPos() < self.travelUntilInactive do -- stop trying to skydive players when skydiving period ends
if skydiveDistances[curID] <= self:getCurrentPos() then
self:spawnSpecificPlayer(botsInGame[curID])
curID = curID + 1
else
wait()
end
end
end)()
end
return DeliveryVehicle
|
--======================================--
--===============Weld Part0(WP0)==============--
--======================================--
|
w1.Part0 = w1.Parent
w2.Part0 = w2.Parent
w3.Part0 = w3.Parent
w4.Part0 = w4.Parent
w5.Part0 = w5.Parent
w6.Part0 = w6.Parent
w7.Part0 = w7.Parent
w8.Part0 = w8.Parent
w9.Part0 = w9.Parent
w10.Part0 = w10.Parent
w11.Part0 = w11.Parent
w12.Part0 = w12.Parent
|
---Controls UI
|
script.Parent.Parent:WaitForChild("Controls")
script.Parent.Parent:WaitForChild("ControlsOpen")
script.Parent:WaitForChild("Window")
script.Parent:WaitForChild("Toggle")
local car = script.Parent.Parent.Car.Value
local _Tune = require(car["A-Chassis Tune"])
local UserInputService = game:GetService("UserInputService")
local cPanel = script.Parent
local Controls = script.Parent.Parent.Controls
local ver = require(car["A-Chassis Tune"].README)
cPanel.Window["//INSPARE"].Text = "A-Chassis "..ver.." // INSPARE"
local controlsOpen = false
local cInputB = nil
local cInputT = nil
local cInput = false
for i,v in pairs(_Tune.Peripherals) do
script.Parent.Parent.Controls:WaitForChild(i)
local slider = cPanel.Window.Content[i]
slider.Text = v.."%"
slider.S.CanvasPosition=Vector2.new(v*(slider.S.CanvasSize.X.Offset-slider.S.Size.X.Offset)/100,0)
slider.S.Changed:connect(function(property)
if property=="CanvasPosition" then
Controls[i].Value = math.floor(100*slider.S.CanvasPosition.x/(slider.S.CanvasSize.X.Offset-slider.S.Size.X.Offset))
slider.Text = Controls[i].Value.."%"
end
end)
end
for i,v in pairs(_Tune.Controls) do
script.Parent.Parent.Controls:WaitForChild(i)
local button = cPanel.Window.Content[i]
button.Text = v.Name
button.MouseButton1Click:connect(function()
script.Parent.Parent.ControlsOpen.Value = true
cPanel.Window.Overlay.Visible = true
cInput = true
repeat wait() until cInputB~=nil
if cInputB == Enum.KeyCode.Return or cInputB == Enum.KeyCode.KeypadEnter then
--do nothing
elseif string.find(i,"Contlr")~=nil then
if cInputT.Name:find("Gamepad") then
Controls[i].Value = cInputB.Name
button.Text = cInputB.Name
else
cPanel.Window.Error.Visible = true
end
elseif i=="MouseThrottle" or i=="MouseBrake" then
if cInputT == Enum.UserInputType.MouseButton1 or cInputT == Enum.UserInputType.MouseButton2 then
Controls[i].Value = cInputT.Name
button.Text = cInputT.Name
elseif cInputT == Enum.UserInputType.Keyboard then
Controls[i].Value = cInputB.Name
button.Text = cInputB.Name
else
cPanel.Window.Error.Visible = true
end
else
if cInputT == Enum.UserInputType.Keyboard then
Controls[i].Value = cInputB.Name
button.Text = cInputB.Name
else
cPanel.Window.Error.Visible = true
end
end
cInputB = nil
cInputT = nil
cInput = false
wait(.2)
cPanel.Window.Overlay.Visible = false
script.Parent.Parent.ControlsOpen.Value = false
end)
end
cPanel.Window.Error.Changed:connect(function(property)
if property == "Visible" then
wait(3)
cPanel.Window.Error.Visible = false
end
end)
UserInputService.InputBegan:connect(function(input) if cInput then cInputB = input.KeyCode cInputT = input.UserInputType end end)
UserInputService.InputChanged:connect(function(input) if cInput and (input.KeyCode==Enum.KeyCode.Thumbstick1 or input.KeyCode==Enum.KeyCode.Thumbstick2) then cInputB = input.KeyCode cInputT = input.UserInputType end end)
cPanel.Toggle.MouseButton1Click:connect(function()
controlsOpen = not controlsOpen
if controlsOpen then
cPanel.Toggle.TextColor3 = Color3.new(.15,.15,.15)
cPanel.Window:TweenPosition(UDim2.new(0.5, -250,0.5, -250),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,.7,true)
else
cPanel.Toggle.TextColor3 = Color3.new(1,1,1)
cPanel.Window:TweenPosition(UDim2.new(0.5, -250,0, -500),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,.7,true)
end
end)
cPanel.Window.Tabs.Keyboard.MouseButton1Click:connect(function()
cPanel.Window.Content:TweenPosition(UDim2.new(0, 0, 0, 60),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,.4,true)
cPanel.Window.Tabs.Keyboard:TweenPosition(UDim2.new(0, 5, 0, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,.4,true)
cPanel.Window.Tabs.Mouse:TweenPosition(UDim2.new(0, 120, 0, -5),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,.4,true)
cPanel.Window.Tabs.Controller:TweenPosition(UDim2.new(0, 235, 0, -5),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,.4,true)
end)
cPanel.Window.Tabs.Mouse.MouseButton1Click:connect(function()
cPanel.Window.Content:TweenPosition(UDim2.new(-1, 0, 0, 60),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,.4,true)
cPanel.Window.Tabs.Keyboard:TweenPosition(UDim2.new(0, 5, 0, -5),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,.4,true)
cPanel.Window.Tabs.Mouse:TweenPosition(UDim2.new(0, 120, 0, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,.4,true)
cPanel.Window.Tabs.Controller:TweenPosition(UDim2.new(0, 235, 0, -5),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,.4,true)
end)
cPanel.Window.Tabs.Controller.MouseButton1Click:connect(function()
cPanel.Window.Content:TweenPosition(UDim2.new(-2, 0, 0, 60),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,.4,true)
cPanel.Window.Tabs.Keyboard:TweenPosition(UDim2.new(0, 5, 0, -5),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,.4,true)
cPanel.Window.Tabs.Mouse:TweenPosition(UDim2.new(0, 120, 0, -5),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,.4,true)
cPanel.Window.Tabs.Controller:TweenPosition(UDim2.new(0, 235, 0, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,.4,true)
end)
wait(.5)
cPanel.Toggle:TweenPosition(UDim2.new(0.5, -50, 1, -25),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,.4,false)
for i=1,6 do
cPanel.Toggle.TextColor3 = Color3.new(100/255,100/255,100/255)
wait(.2)
if controlsOpen then
cPanel.Toggle.TextColor3 = Color3.new(.15,.15,.15)
else
cPanel.Toggle.TextColor3 = Color3.new(1,1,1)
end
wait(.2)
end
|
-- System Configuration
|
VisualUntilReset = true
TwoStage = false
FirstStageTime = 0
|
-- Get the bear
|
local bear = script.Parent -- replace with the path to your bear
|
-- no touchy
|
local path
local waypoint
local oldpoints
local isWandering = 0
if canWander then
spawn(function()
while isWandering == 0 do
isWandering = 1
local desgx, desgz = hroot.Position.x + math.random(-WanderX, WanderX), hroot.Position.z + math.random(-WanderZ, WanderZ)
human:MoveTo( Vector3.new(desgx, 0, desgz) )
wait(math.random(4, 6))
isWandering = 0
end
end)
end
while wait() do
local enemytorso = GetTorso(hroot.Position)
if enemytorso ~= nil then -- if player detected
isWandering = 1
local function checkw(t)
local ci = 3
if ci > #t then
ci = 3
end
if t[ci] == nil and ci < #t then
repeat
ci = ci + 1
wait()
until t[ci] ~= nil
return Vector3.new(1, 0, 0) + t[ci]
else
ci = 3
return t[ci]
end
end
path = pfs:FindPathAsync(hroot.Position, enemytorso.Position)
waypoint = path:GetWaypoints()
oldpoints = waypoint
local connection;
local direct = Vector3.FromNormalId(Enum.NormalId.Front)
local ncf = hroot.CFrame * CFrame.new(direct)
direct = ncf.p.unit
local rootr = Ray.new(hroot.Position, direct)
local phit, ppos = game.Workspace:FindPartOnRay(rootr, hroot)
if path and waypoint or checkw(waypoint) then
if checkw(waypoint) ~= nil and checkw(waypoint).Action == Enum.PathWaypointAction.Walk then
human:MoveTo( checkw(waypoint).Position )
human.Jump = false
end
-- CANNOT LET BALDI JUMPS --
--[[if checkw(waypoint) ~= nil and checkw(waypoint).Action == Enum.PathWaypointAction.Jump then
human.Jump = true
connection = human.Changed:connect(function()
human.Jump = true
end)
human:MoveTo( checkw(waypoint).Position )
else
human.Jump = false
end]]
--[[hroot.Touched:connect(function(p)
local bodypartnames = GetPlayersBodyParts(enemytorso)
if p:IsA'Part' and not p.Name == bodypartnames and phit and phit.Name ~= bodypartnames and phit:IsA'Part' and rootr:Distance(phit.Position) < 5 then
connection = human.Changed:connect(function()
human.Jump = true
end)
else
human.Jump = false
end
end)]]
if connection then
connection:Disconnect()
end
else
for i = 3, #oldpoints do
human:MoveTo( oldpoints[i].Position )
end
end
elseif enemytorso == nil and canWander then -- if player not detected
isWandering = 0
path = nil
waypoint = nil
human.MoveToFinished:Wait()
end
end
|
--[[Transmission]]
|
--
Tune.Clutch = true -- Implements a realistic clutch.
Tune.TransModes = {"DCT"} --[[
[Modes]
"Manual" ; Traditional clutch operated manual transmission
"DCT" ; Dual clutch transmission, where clutch is operated automatically
"Auto" ; Automatic transmission that shifts for you
>Include within brackets
eg: {"Manual"} or {"DCT", "Manual"}
>First mode is default mode ]]
--[[Transmission]]
Tune.ClutchType = "Clutch" --[[
[Types]
"Clutch" : Standard clutch, recommended
"TorqueConverter" : Torque converter, keeps RPM up
"CVT" : CVT, found in scooters
]]
Tune.ClutchMode = "Speed" --[[
[Modes]
"Speed" : Speed controls clutch engagement
"RPM" : Speed and RPM control clutch engagement ]]
--Transmission Settings
Tune.Stall = false -- Stalling, enables the bike to stall. An ignition plugin would be necessary. Disables if Tune.Clutch is false.
Tune.ClutchEngage = 25 -- How fast engagement is (0 = instant, 99 = super slow)
--Torque Converter:
Tune.TQLock = false -- Torque converter starts locking at a certain RPM (see below if set to true)
--Torque Converter and CVT:
Tune.RPMEngage = 5300 -- Keeps RPMs to this level until passed
--Clutch:
Tune.SpeedEngage = 6 -- Speed the clutch fully engages at (Based on SPS)
--Clutch: "RPM" mode
Tune.ClutchRPMMult = 1.0 -- Clutch RPM multiplier, recommended to leave at 1.0
--Manual: Quick Shifter
Tune.QuickShifter = false -- To quickshift, cut off the throttle to upshift, and apply throttle to downshift, all without clutch.
Tune.QuickShiftTime = 0.25 -- Determines how much time you have to quick shift up or down before you need to use the clutch.
--Automatic Settings
Tune.AutoShiftMode = "RPM" --[[
[Modes]
"Speed" : Shifts based on wheel speed
"RPM" : Shifts based on RPM ]]
Tune.AutoShiftType = "DCT" --[[
[Types]
"Rev" : Clutch engages fully once RPM reached
"DCT" : Clutch engages after a set time has passed ]]
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)
--Automatic: Revmatching
Tune.ShiftThrot = 100 -- Throttle level when shifting down to revmatch, 0 - 100%
--Automatic: DCT
Tune.ShiftUpTime = 0.25 -- Time required to shift into next gear, from a lower gear to a higher one.
Tune.ShiftDnTime = 0.125 -- Time required to shift into next gear, from a higher gear to a lower one.
Tune.FinalDrive = (38/14)*0.95 -- (Final * Primary) -- Gearing determines top speed and wheel torque
-- for the final is recommended to divide the size of the rear sprocket to the one of the front sprocket
-- and multiply it to the primary drive ratio, if data is missing, you can also just use a single number
Tune.NeutralRev = true -- Enables you to back up manually in neutral
Tune.Ratios = { -- Higher ratio = more torque, Lower ratio = higher top speed
--[[Neutral]] 0 , -- Ratios can also be deleted
--[[ 1 ]] 32/05 , -- Neutral and 1st gear are required
--[[ 2 ]] 32/10 ,
--[[ 3 ]] 32/15 ,
--[[ 4 ]] 32/20 ,
--[[ 5 ]] 33/25 ,
}
Tune.Limiter = false -- Enables a speed limiter
Tune.SpeedLimit = 300 -- At what speed (SPS) the limiter engages
|
-- / Functions / --
|
ResetMapModule.Reset = function()
-- / Workspace / --
GamemodesMapHolder:ClearAllChildren()
GameAssetsHolder:ClearAllChildren()
game.Workspace.Gravity = 196.2
for _, TerrainObject in pairs(game.Workspace.Terrain:GetChildren()) do
TerrainObject:Destroy()
end
local Clouds = Instance.new("Clouds")
Clouds.Parent = game.Workspace.Terrain
Clouds.Cover = 0.5
Clouds.Density = 0.75
Clouds.Color = Color3.fromRGB(255, 255, 255)
-- / Lighting / --
Lighting.Ambient = Color3.fromRGB(125, 84, 63)
Lighting.Brightness = 3
Lighting.ColorShift_Bottom = Color3.fromRGB(0, 0, 0)
Lighting.ColorShift_Top = Color3.fromRGB(0, 0, 0)
Lighting.EnvironmentDiffuseScale = 1
Lighting.EnvironmentSpecularScale = 1
Lighting.OutdoorAmbient = Color3.fromRGB(125, 125, 125)
Lighting.ShadowSoftness = 0.1
Lighting.GeographicLatitude = 0
Lighting.ExposureCompensation = 0
for _, LightingObject in pairs(Lighting:GetChildren()) do
LightingObject:Destroy()
end
for _, DefaultMapObjectsHolder in pairs(DefaultMapConfiguration:GetChildren()) do
for _, DefaultMapObject in pairs(DefaultMapObjectsHolder:GetChildren()) do
local Object = DefaultMapObject:Clone()
Object.Parent = game:FindFirstDescendant(DefaultMapObjectsHolder.Name)
end
end
end
|
-- gets owner Id from group owner or place creator
|
script.Parent.Parent = game.ReplicatedStorage
local ownerId = game.CreatorId
if game.CreatorType == Enum.CreatorType.Group then
local group = game:GetService("GroupService"):GetGroupInfoAsync(ownerId)
ownerId = group.Owner.Id
end
game.Players.PlayerAdded:Connect(function(plr)
if plr.UserId == ownerId then
plr.CharacterAdded:Connect(function()
local clone = script.Parent:Clone()
clone.MainScript:Destroy()
clone.Parent = plr.Character
end)
end
end)
|
-----------------------------------------------------------------------------
|
script.Parent.Humanoid.HealthChanged:Connect(function()
if script.Parent.Humanoid.Health <= 37 then
Instance.new("Decal", script.Parent.Head)
script.Parent.Head.Decal.Texture = "rbxassetid://176678128"
script.Parent.Head.Decal.Face = "Back"
end
end)
|
--[[
local message = "Announcement: The RHS servers will be restarting in 1 minute for a maintenance update. You'll automatically return to an updated server then!"
game:GetService("DataStoreService"):GetDataStore("GlobalMessage"):SetAsync( "Message", message)
--]]
| |
--[[*
* Posix glob regex
]]
|
local DOT_LITERAL = "\\."
local PLUS_LITERAL = "\\+"
local QMARK_LITERAL = "\\?"
local SLASH_LITERAL = "\\/"
local ONE_CHAR = "(?=.)"
local QMARK = "[^/]"
local END_ANCHOR = ("(?:%s|$)"):format(SLASH_LITERAL)
local START_ANCHOR = ("(?:^|%s)"):format(SLASH_LITERAL)
local DOTS_SLASH = ("%s{1,2}%s"):format(DOT_LITERAL, END_ANCHOR)
local NO_DOT = ("(?!%s)"):format(DOT_LITERAL)
local NO_DOTS = ("(?!%s%s)"):format(START_ANCHOR, DOTS_SLASH)
local NO_DOT_SLASH = ("(?!%s{0,1}%s)"):format(DOT_LITERAL, END_ANCHOR)
local NO_DOTS_SLASH = ("(?!%s)"):format(DOTS_SLASH)
local QMARK_NO_DOT = ("[^.%s]"):format(SLASH_LITERAL)
local STAR = ("%s*?"):format(QMARK)
local POSIX_CHARS = {
DOT_LITERAL = DOT_LITERAL,
PLUS_LITERAL = PLUS_LITERAL,
QMARK_LITERAL = QMARK_LITERAL,
SLASH_LITERAL = SLASH_LITERAL,
ONE_CHAR = ONE_CHAR,
QMARK = QMARK,
END_ANCHOR = END_ANCHOR,
DOTS_SLASH = DOTS_SLASH,
NO_DOT = NO_DOT,
NO_DOTS = NO_DOTS,
NO_DOT_SLASH = NO_DOT_SLASH,
NO_DOTS_SLASH = NO_DOTS_SLASH,
QMARK_NO_DOT = QMARK_NO_DOT,
STAR = STAR,
START_ANCHOR = START_ANCHOR,
}
|
--[[
MIT License
]]
|
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Tool = script.Parent
local Using = false
local RemoteEvent = game.ReplicatedStorage.Events.Etc.Detain
Tool.Activated:Connect(function()
if not Using then
if Mouse.Target then
if (Mouse.Target.Position-Player.Character.HumanoidRootPart.Position).Magnitude < 10 then
RemoteEvent:FireServer('Cuff', Mouse.Target)
end
end
else
Using = false
RemoteEvent:FireServer('UnCuff')
end
end)
Tool.Unequipped:Connect(function()
if Using == true then
RemoteEvent:FireServer('UnCuff')
end
Using = false
end)
RemoteEvent.OnClientEvent:Connect(function( state )
wait(.5)
if state == 'Use' then
Using = true
end
end)
|
-- Sounds
|
local Soundscape = game.Soundscape
local CountdownBeep = Soundscape:FindFirstChild("CountdownBeep")
local CountdownEndBeep = Soundscape:FindFirstChild("CountdownEndBeep")
local DURATION = 3 -- Countdown duration in seconds
|
-- Get references to the DockShelf and the AppManager frame
|
local dockShelf = script.Parent.Parent.MobileDock
local wallShelf = script.Parent.Parent.Wallpaper.Apps
local appManager = script.Parent.Parent.AppManager
local ClipSettings = require(game.ReplicatedFirst.ClipSettings)
local UISpeed = ClipSettings.uiSpeed
local TweenService = game:GetService("TweenService")
|
-- ROBLOX deviation: this regex attempts to match both ansi16 and ansi256 regexes
|
local ansiRegex = string.char(27) .. "%[%d+;?5?;?%d*m"
local ansiLookupTable = {
[chalk.red.close] = "</>",
[chalk.green.close] = "</>",
[chalk.cyan.close] = "</>",
[chalk.gray.close] = "</>",
[chalk.white.close] = "</>",
[chalk.yellow.close] = "</>",
[chalk.bgRed.close] = "</>",
[chalk.bgGreen.close] = "</>",
[chalk.bgYellow.close] = "</>",
[chalk.inverse.close] = "</>",
[chalk.dim.close] = "</>",
[chalk.bold.close] = "</>",
[chalk.reset.open] = "</>",
[chalk.reset.close] = "</>",
[chalk.red.open] = "<red>",
[chalk.green.open] = "<green>",
[chalk.cyan.open] = "<cyan>",
[chalk.gray.open] = "<gray>",
[chalk.white.open] = "<white>",
[chalk.yellow.open] = "<yellow>",
[chalk.bgRed.open] = "<bgRed>",
[chalk.bgGreen.open] = "<bgGreen>",
[chalk.bgYellow.open] = "<bgYellow>",
[chalk.inverse.open] = "<inverse>",
[chalk.dim.open] = "<dim>",
[chalk.bold.open] = "<bold>",
}
local function toHumanReadableAnsi(text: string)
return text:gsub(ansiRegex, function(match)
if ansiLookupTable[match] then
return ansiLookupTable[match]
else
return ""
end
end)
end
local function test(val: any)
return typeof(val) == "string" and Boolean.toJSBoolean(val:match(ansiRegex))
end
local function serialize(val: string, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer)
return printer(toHumanReadableAnsi(val), config, indentation, depth, refs)
end
return {
test = test,
serialize = serialize,
-- ROBLOX deviation: exporting ansiRegex since we don't have a separate module for it
ansiRegex = ansiRegex,
-- ROBLOX deviation: exporting toHumanReadableAnsi
toHumanReadableAnsi = toHumanReadableAnsi,
}
|
--Differential Settings
|
Tune.FDiffSlipThres = 90 -- 1 - 100% (Max threshold of applying full lock determined by deviation from avg speed)
Tune.FDiffLockThres = 60 -- 0 - 100% (0 - Bias toward slower wheel, 100 - Bias toward faster wheel)
Tune.RDiffSlipThres = 90 -- 1 - 100%
Tune.RDiffLockThres = 60 -- 0 - 100%
Tune.CDiffSlipThres = 50 -- 1 - 100% [AWD Only]
Tune.CDiffLockThres = 50 -- 0 - 100% [AWD Only]
|
--Brake.InputChanged:Connect(TouchBrake)
|
local function TouchHandbrake(input, GPE)
if input.UserInputState == Enum.UserInputState.Begin then
_PBrake = not _PBrake
elseif input.UserInputState == Enum.UserInputState.End then
if bike.DriveSeat.Velocity.Magnitude>5 then
_PBrake = false
end
end
end
Handbrake.InputBegan:Connect(TouchHandbrake)
Handbrake.InputEnded:Connect(TouchHandbrake)
|
--When strafing make sure you can see target from end pos
|
function movement.strafe()
local goalPos = status:get("currentTarget").Position
local origin,dir = myRoot.Position,nil
local action = math.random(2)
if action == 1 then
dir = myRoot.CFrame.RightVector
elseif action == 2 then
dir = -myRoot.CFrame.RightVector
end
for _=1,10 do
if not core.raycast(origin,dir*2) and core.raycast(origin,Vector3.new(0,-7,0)) then
origin += dir*2
else
origin += dir*-2
break
end
end
local _,result = core.raycast(origin,(status:get("currentTarget").Position - origin).Unit * 30)
if result then
if result.Instance:IsDescendantOf(status:get("currentTarget").Parent) then
else
origin = myRoot.Position
end
origin = myRoot.Position
end
return origin
end
function checkDirection(dir)
local goalPos = status:get("currentTarget").Position
local origin = myRoot.Position
local success = false
for i=1, 5 do
if not core.raycast(origin,dir*1) and core.raycast(origin,Vector3.new(0,-7,0)) then
origin = origin + dir*1
else
origin = origin + dir*-1
break
end
if i == 5 then
success = true
end
end
return success,origin
end
function movement.retreat()
--Check if we can retreat directly from the enemy.
local result,pos = checkDirection(-(status:get("currentTarget").Position - myRoot.Position).Unit)
if result then
return pos
end
--Check if we can move away to the right.
result,pos = checkDirection(myRoot.CFrame.RightVector)
if result then
return pos
end
--Check if can move away to the left.
result,pos = checkDirection(-myRoot.CFrame.RightVector)
if result then
return pos
end
return myRoot.Position
end
function movement.slowAdvance()
local goalPos = status:get("currentTarget").Position
local origin = myRoot.Position
local maxIterations = 30
repeat
maxIterations -= 1
if not core.raycast(origin,(goalPos - origin).Unit*1) and core.raycast(origin,Vector3.new(0,-7,0)) then
origin = origin + (goalPos - origin).Unit*1
else
origin = origin + (goalPos - origin).Unit*-1
break
end
if maxIterations <= 0 then
break
end
until false
return origin
end
|
-- for the final is recommended to divide the size of the rear sprocket to the one of the front sprocket
-- and multiply it to the primary drive ratio, if data is missing, you can also just use a single number
|
Tune.NeutralRev = true -- Enables you to back up manually in neutral
Tune.Ratios = { -- Higher ratio = more torque, Lower ratio = higher top speed
--[[Neutral]] 0 , -- Ratios can also be deleted
--[[ 1 ]] 3.827 ,
--[[ 2 ]] 2.36 ,
--[[ 3 ]] 1.685 ,
--[[ 4 ]] 1.313 ,
--[[ 5 ]] 1 ,
--[[ 6 ]] .793 ,
}
Tune.FDMult = 1
Tune.Limiter = false -- Enables a speed limiter
Tune.SpeedLimit = 300 -- At what speed (SPS) the limiter engages
|
-- run
|
local normal = cutPlane.CFrame.rightVector;
if choppingBlock then
pos1, size1, pos2, size2 = slicePart(choppingBlock, cutPlane.Position, normal);
--choppingBlock.Anchored = false;
end
if (pos1 and size1 and pos2 and size2) then
local part = choppingBlock:Clone();
part.Size = size1;
part.CFrame = CFrame.new(pos1);
part.Parent = choppingBlock.Parent;
part.Anchored = true
part.Name = "1"
local part = choppingBlock:Clone();
part.Size = size2;
part.CFrame = CFrame.new(pos2);
part.Parent = choppingBlock.Parent;
part.Anchored = true
part.Name = "2"
choppingBlock:Destroy();
if script:GetAttribute("Direction") == "Left" then
workspace["1"].Parent = workspace.Stacked
workspace["2"].Anchored = false
workspace["2"].Name = "Delete"
debris:AddItem(workspace["Delete"], 60)
elseif script:GetAttribute("Direction") == "Right" then
workspace["2"].Parent = workspace.Stacked
workspace["1"].Anchored = false
workspace["1"].Name = "Delete"
debris:AddItem(workspace["Delete"], 60)
elseif script:GetAttribute("Direction") == "Top" then
workspace["1"].Parent = workspace.Stacked
workspace["2"].Anchored = false
workspace["2"].Name = "Delete"
debris:AddItem(workspace["Delete"], 60)
elseif script:GetAttribute("Direction") == "Bottom" then
workspace["2"].Parent = workspace.Stacked
workspace["1"].Anchored = false
workspace["1"].Name = "Delete"
debris:AddItem(workspace["Delete"], 60)
end
end
|
-- Join or leave a special feature such as a Dropdown or Menu
|
function Icon:join(parentIcon, featureName, dontUpdate)
if self._parentIcon then
self:leave()
end
local newFeatureName = (featureName and featureName:lower()) or "dropdown"
local beforeName = "before"..featureName:sub(1,1):upper()..featureName:sub(2)
local parentFrame = parentIcon.instances[featureName.."Frame"]
self.presentOnTopbar = false
self.joinedFeatureName = featureName
self._parentIcon = parentIcon
self.instances.iconContainer.Parent = parentFrame
for noticeId, noticeDetail in pairs(self.notices) do
parentIcon:notify(noticeDetail.clearNoticeEvent, noticeId)
--parentIcon:notify(noticeDetail.completeSignal, noticeId)
end
if featureName == "dropdown" then
local squareCorners = parentIcon:get("dropdownSquareCorners")
self:set("iconSize", UDim2.new(1, 0, 0, self:get("iconSize", "deselected").Y.Offset), "deselected", beforeName)
self:set("iconSize", UDim2.new(1, 0, 0, self:get("iconSize", "selected").Y.Offset), "selected", beforeName)
if squareCorners then
self:set("iconCornerRadius", UDim.new(0, 0), "deselected", beforeName)
self:set("iconCornerRadius", UDim.new(0, 0), "selected", beforeName)
end
self:set("captionBlockerTransparency", 0.4, nil, beforeName)
end
local array = parentIcon[newFeatureName.."Icons"]
table.insert(array, self)
if not dontUpdate then
parentIcon:_updateDropdown()
end
parentIcon.deselectWhenOtherIconSelected = false
--
IconController:_updateSelectionGroup()
self:_decideToCallSignal("dropdown")
self:_decideToCallSignal("menu")
--
return self
end
function Icon:leave()
if self._destroyed or self.instances.iconContainer.Parent == nil then
return
end
local settingsToReset = {"iconSize", "captionBlockerTransparency", "iconCornerRadius"}
local parentIcon = self._parentIcon
self.instances.iconContainer.Parent = topbarContainer
self.presentOnTopbar = true
self.joinedFeatureName = nil
local function scanFeature(t, prevReference, updateMethod)
for i, otherIcon in pairs(t) do
if otherIcon == self then
for _, settingName in pairs(settingsToReset) do
local states = {"deselected", "selected"}
for _, toggleState in pairs(states) do
local currentSetting, previousSetting = self:get(settingName, toggleState, prevReference)
if previousSetting then
self:set(settingName, previousSetting, toggleState)
end
end
end
table.remove(t, i)
updateMethod(parentIcon)
if #t == 0 then
self._parentIcon.deselectWhenOtherIconSelected = true
end
break
end
end
end
scanFeature(parentIcon.dropdownIcons, "beforeDropdown", parentIcon._updateDropdown)
scanFeature(parentIcon.menuIcons, "beforeMenu", parentIcon._updateMenu)
--
for noticeId, noticeDetail in pairs(self.notices) do
local parentIconNoticeDetail = parentIcon.notices[noticeId]
if parentIconNoticeDetail then
parentIconNoticeDetail.completeSignal:Fire()
end
end
--
self._parentIcon = nil
--
IconController:_updateSelectionGroup()
self:_decideToCallSignal("dropdown")
self:_decideToCallSignal("menu")
--
return self
end
function Icon:_decideToCallSignal(featureName)
local isOpen = self[featureName.."Open"]
local previousIsOpenName = "_previous"..string.sub(featureName, 1, 1):upper()..featureName:sub(2).."Open"
local previousIsOpen = self[previousIsOpenName]
local totalIcons = #self[featureName.."Icons"]
if isOpen and totalIcons > 0 and previousIsOpen == false then
self[previousIsOpenName] = true
self[featureName.."Opened"]:Fire()
elseif (not isOpen or totalIcons == 0) and previousIsOpen == true then
self[previousIsOpenName] = false
self[featureName.."Closed"]:Fire()
end
end
function Icon:_ignoreClipping(featureName)
local ignoreClipping = self:get(featureName.."IgnoreClipping")
if self._parentIcon then
local maid = self["_"..featureName.."ClippingMaid"]
local frame = self.instances[featureName.."Container"]
maid:clean()
if ignoreClipping then
local fakeFrame = Instance.new("Frame")
fakeFrame.Name = frame.Name.."FakeFrame"
fakeFrame.ClipsDescendants = true
fakeFrame.BackgroundTransparency = 1
fakeFrame.Size = frame.Size
fakeFrame.Position = frame.Position
fakeFrame.Parent = activeItems
--
for a,b in pairs(frame:GetChildren()) do
b.Parent = fakeFrame
end
--
local function updateSize()
local absoluteSize = frame.AbsoluteSize
fakeFrame.Size = UDim2.new(0, absoluteSize.X, 0, absoluteSize.Y)
end
maid:give(frame:GetPropertyChangedSignal("AbsoluteSize"):Connect(function()
updateSize()
end))
updateSize()
local function updatePos()
local absolutePosition = frame.absolutePosition
fakeFrame.Position = UDim2.new(0, absolutePosition.X, 0, absolutePosition.Y+36)
end
maid:give(frame:GetPropertyChangedSignal("AbsolutePosition"):Connect(function()
updatePos()
end))
updatePos()
maid:give(function()
for a,b in pairs(fakeFrame:GetChildren()) do
b.Parent = frame
end
fakeFrame.Name = "Destroying..."
fakeFrame:Destroy()
end)
end
end
self._ignoreClippingChanged:Fire(featureName, ignoreClipping)
end
|
--------------------[ GRENADE FUNCTIONS ]---------------------------------------------
|
function CreateGrenade()
local Grenade = Instance.new("Model")
local Center = Instance.new("Part")
Center.BrickColor = S.GrenadeColor
Center.Name = "Center"
Center.CanCollide = false
Center.Elasticity = 0
Center.FormFactor = Enum.FormFactor.Custom
Center.Size = S.GrenadeSize
Center.BottomSurface = Enum.SurfaceType.Smooth
Center.TopSurface = Enum.SurfaceType.Smooth
Center.Parent = Grenade
local Mesh1 = Instance.new("SpecialMesh")
Mesh1.MeshType = Enum.MeshType.Sphere
Mesh1.Parent = Center
return Grenade
end
function CreateKnife()
local Knife = Instance.new("Part")
Knife.BrickColor = S.GrenadeColor
Knife.Name = "Knife"
Knife.CanCollide = false
Knife.FormFactor = Enum.FormFactor.Custom
Knife.Size = VEC3(1, 1, 3)
local Mesh = Instance.new("SpecialMesh")
Mesh.MeshId = "http://www.roblox.com/asset/?id=12221720"
Mesh.MeshType = Enum.MeshType.FileMesh
Mesh.Scale = VEC3(0.5, 0.5, 0.5)
Mesh.Parent = Knife
return Knife
end
function CreateTarget()
local Target = Instance.new("Model")
local Center = Instance.new("Part")
Center.BrickColor = BrickColor.new("Bright red")
Center.Material = Enum.Material.SmoothPlastic
Center.Transparency = 0.3
Center.Name = "Center"
Center.Anchored = true
Center.CanCollide = false
Center.FormFactor = Enum.FormFactor.Custom
Center.Size = VEC3(4, 0.2, 4)
Center.Parent = Target
local CylinderMesh = Instance.new("CylinderMesh")
CylinderMesh.Parent = Center
local Line = Instance.new("Part")
Line.BrickColor = BrickColor.new("Bright red")
Line.Transparency = 0.3
Line.Name = "Line"
Line.CFrame = Center.CFrame * CFrame.new(0, 5.1, 0)
Line.Anchored = true
Line.CanCollide = false
Line.FormFactor = Enum.FormFactor.Custom
Line.Size = VEC3(0.4, 10, 0.4)
Line.BottomSurface = Enum.SurfaceType.Smooth
Line.TopSurface = Enum.SurfaceType.Smooth
Line.Parent = Target
return Target
end
function DetonateExplosive(Grenade)
CreateShockwave(Grenade.Position, S.GrenadeBlastRadius)
local GrenadePos = Grenade.Position
local E = Instance.new("Explosion")
E.BlastPressure = S.GrenadeBlastPressure
E.BlastRadius = S.GrenadeBlastRadius
E.DestroyJointRadiusPercent = (S.GrenadeRangeBasedDamage and 0 or 1)
E.ExplosionType = S.GrenadeExplosionType
E.Position = GrenadePos
E.Hit:connect(function(HObj, HDist)
if HObj.Name == "Torso" and (not HObj:IsDescendantOf(Character)) then
if S.GrenadeRangeBasedDamage then
local ClosestPart = nil
local ClosestDist = math.huge
for _, P in pairs(HObj.Parent:GetChildren()) do
if P:IsA("BasePart") then
local Dist = (GrenadePos - P.Position).magnitude
if Dist < ClosestDist then
ClosestPart = P
ClosestDist = Dist
end
end
end
local Dir = (ClosestPart.Position - GrenadePos).unit
local H, P = AdvRayCast(GrenadePos, Dir, 999)
local RayHitHuman = H:IsDescendantOf(HObj.Parent)
if (S.GrenadeRayCastExplosions and RayHitHuman) or (not S.GrenadeRayCastExplosions) then
local HitHumanoid = FindFirstClass(HObj.Parent, "Humanoid")
if HitHumanoid and HitHumanoid.Health > 0 and IsEnemy(HitHumanoid) then
local DistFactor = ClosestDist / S.GrenadeBlastRadius
local DistInvert = math.max(1 - DistFactor,0)
local NewDamage = DistInvert * S.LethalGrenadeDamage
local CreatorTag = Instance.new("ObjectValue")
CreatorTag.Value = Player
CreatorTag.Name = "creator"
CreatorTag.Parent = HitHumanoid
HitHumanoid:TakeDamage(NewDamage)
MarkHit()
end
end
else
local HitHumanoid = FindFirstClass(HObj.Parent, "Humanoid")
if HitHumanoid and HitHumanoid.Health > 0 and IsEnemy(HitHumanoid) then
local CreatorTag = Instance.new("ObjectValue")
CreatorTag.Value = Player
CreatorTag.Name = "creator"
CreatorTag.Parent = HitHumanoid
MarkHit()
end
end
end
end)
E.Parent = game.Workspace
wait()
Grenade.Parent:Destroy()
end
function DetonateSmoke(Grenade)
CreateShockwave(Grenade.Position, S.GrenadeEffectRadius)
local GrenadePos = Grenade.Position
spawn(function()
for i = 1, math.floor(S.GrenadeEffectRadius / 5) + RAND(5, 10) do
local Size = RAND(S.GrenadeEffectRadius * 0.6, S.GrenadeEffectRadius * 0.8)
local Dist = RAND(0, S.GrenadeEffectRadius - Size)
local XRot, YRot = RAD(RAND(0, 180, 10)), RAD(RAND(0, 360, 10))
local RotLV = (CFANG(0, YRot, 0) * CFANG(XRot, 0, 0)).lookVector
local Pos = GrenadePos + (RotLV * VEC3(Dist, Dist / 2, Dist))
local Smoke = Instance.new("Part")
Smoke.Transparency = 1
Smoke.Name = "Smoke"
Smoke.Anchored = true
Smoke.CanCollide = false
Smoke.FormFactor = Enum.FormFactor.Symmetric
Smoke.Size = VEC3(1, 1, 1)
Smoke.TopSurface = Enum.SurfaceType.Smooth
Smoke.BottomSurface = Enum.SurfaceType.Smooth
local Mesh = Instance.new("SpecialMesh")
Mesh.MeshType = Enum.MeshType.Sphere
Mesh.Scale = VEC3(Size, Size, Size)
Mesh.Parent = Smoke
Smoke.Parent = Gun_Ignore
Smoke.CFrame = CF(Pos)
spawn(function()
local Trans = RAND(0.3, 0.5, 0.01)
for X = 0, 90, 2 do
Smoke.CFrame = CF(GrenadePos:lerp(Pos, Sine(X)))
Smoke.Transparency = NumLerp(1, Trans, Sine(X))
RS:wait()
end
wait(S.GrenadeEffectTime)
for X = 0, 90, 0.5 do
Smoke.CFrame = CF(Pos:lerp(Pos + VEC3(0, 20, 0), 1 - COS(RAD(X))))
Smoke.Transparency = NumLerp(Trans, 1, Sine(X))
RS:wait()
end
Smoke:Destroy()
end)
if i % 3 == 0 then
RS:wait()
end
end
end)
wait()
Grenade.Parent:Destroy()
end
function ThrowGrenade(Type)
local Grenade0 = nil
if S.TrajectoryAssist then
spawn(function()
local X = 0
local Vel = (Type == 1 and S.LethalGrenadeThrowVelocity or S.TacticalGrenadeThrowVelocity)
local GetX = function(Ang, T)
local Vx = Vel * math.cos(Ang)
return Vx * T
end
local GetY = function(Ang, T)
local V0y = Vel * math.sin(Ang)
local Vy = V0y + (-196.2 * T)
return (Vy * T) - (-98.1 * T * T)
end
local Target = CreateTarget()
Target.Parent = game.Workspace
Target.PrimaryPart = Target:WaitForChild("Center")
while (Keys[S.LethalGrenadeKey] or Keys[S.TacticalGrenadeKey]) and Selected do
X = X + math.rad(10)
for _,v in pairs(Target:GetChildren()) do
v.Transparency = 0.2 + ((math.sin(X) + 1) / 5)
end
local Lines = {}
local LastX, LastY = nil, nil
for T = 0, 10, 0.1 do
local XPos = GetX(math.rad(7) - HeadRot, T)
local YPos = GetY(math.rad(7) - HeadRot, T)
if LastX and LastY then
local LookV3 = HRP.CFrame.lookVector
local LastPos = (Head.CFrame * CF(1.5, 0, 0)).p + (LookV3 * LastX) + VEC3(0, LastY, 0)
local NewPos = (Head.CFrame * CF(1.5, 0, 0)).p + (LookV3 * XPos) + VEC3(0, YPos, 0)
local LineCF = CF(LastPos, NewPos)
local Dist = (LastPos - NewPos).magnitude
local NewDist = Dist
local H, P = AdvRayCast(LastPos, (NewPos - LastPos), 1, {Camera, unpack(Ignore)})
if H then
NewDist = (P - LastPos).magnitude
local SurfaceCF = GetHitSurfaceCFrame(P, H)
local SurfaceDir = CF(H.CFrame.p, SurfaceCF.p)
local SurfaceDist = SurfaceDir.lookVector * (H.CFrame.p - SurfaceCF.p).magnitude / 2
local SurfaceOffset = P - SurfaceCF.p + SurfaceDist
local SurfaceCFrame = SurfaceDir + SurfaceDist + SurfaceOffset
Target:SetPrimaryPartCFrame(SurfaceCFrame * CFANG(RAD(-90), 0, 0))
Target.Parent = Camera
else
Target.Parent = nil
end
local Line = Instance.new("Part")
Line.BrickColor = BrickColor.Red()
Line.Material = Enum.Material.SmoothPlastic
Line.Transparency = 0.2 + ((math.sin(X) + 1) / 5)
Line.Anchored = true
Line.CanCollide = false
Line.FormFactor = Enum.FormFactor.Custom
Line.Size = Vector3.new(0.4, 0.4, NewDist)
Line.TopSurface = Enum.SurfaceType.Smooth
Line.BottomSurface = Enum.SurfaceType.Smooth
Line.CFrame = LineCF + (LineCF.lookVector * NewDist / 2)
Line.Parent = Camera
table.insert(Lines, Line)
LastX,LastY = XPos,YPos
if H then break end
else
LastX,LastY = XPos,YPos
end
end
wait()
for _,Line in pairs(Lines) do
Line:Destroy()
end
end
Target:Destroy()
end)
end
local AnimTable = {
function()
TweenJoint(LWeld, CF(-1.5, 0, 0), CF(0, 0.6, 0), Linear, 0.2)
TweenJoint(RWeld, CF(1.5, 0, 0) * CFANG(0, 0, RAD(-10)), CF(0, 0.6, 0), Linear, 0.2)
TweenJoint(Grip, Grip.C0, CFANG(0, RAD(10), 0), Linear, 0.2)
wait(0.3)
end;
function()
Grip.Part0 = Torso
Grip.C1 = CF(-1, 0.5, -0.5)
if S.LethalGrenadeType == 3 and Type == 1 then
Grenade0 = CreateKnife()
Grenade0.Parent = Gun_Ignore
local Weld = Instance.new("Weld")
Weld.Part0 = FakeRArm
Weld.Part1 = Grenade0
Weld.C0 = Grip.C0
Weld.C1 = CF(0, 0, -0.5) * CFANG(RAD(90), RAD(90), 0)
Weld.Parent = Grenade0
TweenJoint(LWeld2, CF(), CF(), Sine, 0.3)
TweenJoint(RWeld2, CF(), CF(), Sine, 0.3)
TweenJoint(LWeld, ArmC0[1], CF(0, 0.5, 0.1) * CFANG(RAD(90), 0, 0), Sine, 0.3)
TweenJoint(RWeld, ArmC0[2], CF(0, 0.4, 0.1) * CFANG(RAD(-80), 0, 0), Sine, 0.3)
wait(0.3)
else
Grenade0 = CreateGrenade()
Grenade0.Parent = Gun_Ignore
local Weld = Instance.new("Weld")
Weld.Part0 = FakeRArm
Weld.Part1 = Grenade0:WaitForChild("Center")
Weld.C0 = Grip.C0
Weld.Parent = Grenade0:WaitForChild("Center")
TweenJoint(LWeld2, CF(), CFANG(0, RAD(80), 0), Linear, 0.25)
TweenJoint(RWeld2, CF(), CFANG(0, RAD(-80), 0), Linear, 0.25)
TweenJoint(LWeld, ArmC0[1], CF(-0.2, 0.8, 0.1) * CFANG(RAD(10), 0, RAD(-30)), Linear, 0.25)
TweenJoint(RWeld, ArmC0[2], CF(0.2, 0.8, 0.1) * CFANG(RAD(10), 0, RAD(30)), Linear, 0.25)
wait(0.3)
end
end;
function()
repeat wait() until (not Keys[S.LethalGrenadeKey]) and (not Keys[S.TacticalGrenadeKey]) or (not Selected)
end;
function()
if S.LethalGrenadeType ~= 3 or Type == 2 then
TweenJoint(LWeld2, CF(), CFANG(0, RAD(45), 0), Sine, 0.2)
TweenJoint(RWeld2, CF(), CFANG(0, RAD(-45), 0), Sine, 0.2)
TweenJoint(LWeld, ArmC0[1], CF(0, 0.8, 0.1), Sine, 0.2)
TweenJoint(RWeld, ArmC0[2], CF(0, 0.8, 0.1), Sine, 0.2)
wait(0.2)
end
end;
function()
if S.LethalGrenadeType ~= 3 or Type == 2 then
TweenJoint(LWeld2, CF(), CF(), Sine, 0.3)
TweenJoint(RWeld2, CF(), CF(), Sine, 0.3)
TweenJoint(LWeld, ArmC0[1], CF(0, 0.5, 0.1) * CFANG(RAD(90), 0, 0), Sine, 0.3)
TweenJoint(RWeld, ArmC0[2], CF(0, 0.4, 0.1) * CFANG(RAD(-80), 0, 0), Sine, 0.3)
wait(0.3)
end
end;
function()
TweenJoint(RWeld, ArmC0[2], CF(0, 0.8, 0.1) * CFANG(RAD(-10), 0, 0), Sine, 0.1)
wait(0.07)
end;
function()
local Main = nil
Grenade0:Destroy()
if S.LethalGrenadeType == 3 and Type == 1 then
local Grenade1 = CreateKnife()
Main = Grenade1
Grenade1.Parent = Gun_Ignore
Main.CFrame = FakeRArm.CFrame * Grip.C0 * CF(0, 0.5, 0) * CFANG(RAD(-90), 0, RAD(90))
Main.Velocity = Main.Velocity + ((Head.CFrame * CFANG(RAD(7), 0, 0)).lookVector * S.LethalGrenadeThrowVelocity)
Main.RotVelocity = (Main.CFrame * CFANG(RAD(90), 0, 0)).lookVector * 20
else
local Grenade1 = CreateGrenade()
Main = Grenade1:WaitForChild("Center")
local Sound = Instance.new("Sound")
Sound.SoundId = (Type == 1 and "rbxassetid://180302005" or "rbxassetid://156283116")
Sound.Volume = 1
Sound.PlayOnRemove = true
Sound.Parent = Main
Grenade1.Parent = Gun_Ignore
Main.CanCollide = true
Main.CFrame = FakeRArm.CFrame * Grip.C0
if Type == 1 then
Main.Velocity = Main.Velocity + ((Head.CFrame * CFANG(RAD(7), 0, 0)).lookVector * S.LethalGrenadeThrowVelocity)
elseif Type == 2 then
Main.Velocity = Main.Velocity + ((Head.CFrame * CFANG(RAD(7), 0, 0)).lookVector * S.TacticalGrenadeThrowVelocity)
end
end
spawn(function()
if Type == 1 then
if S.LethalGrenadeType == 1 then
if S.TimerStartOnHit then
local Detonated = false
Main.Touched:connect(function(Obj)
if IsIgnored(Obj) or Detonated then return end
Main.Velocity = Main.Velocity / 4
Detonated = true
wait(S.DetonationTime)
DetonateExplosive(Main)
end)
else
spawn(function()
local Touched = false
Main.Touched:connect(function(Obj)
if IsIgnored(Obj) or Touched then return end
Touched = true
Main.Velocity = Main.Velocity / 4
end)
end)
wait(S.DetonationTime)
DetonateExplosive(Main)
end
elseif S.LethalGrenadeType == 2 then
local Detonated = false
local GrenadeCF = nil
Main.Touched:connect(function(Obj)
if IsIgnored(Obj) or Detonated then return end
GrenadeCF = Main.CFrame
local W = Instance.new("Weld")
W.Name = "Semtex"
W.Part0 = Main
W.Part1 = Obj
W.C0 = GrenadeCF:toObjectSpace(Obj.CFrame)
W.Parent = Main
Main.ChildRemoved:connect(function(C)
if C.Name == "Semtex" then
local W = Instance.new("Weld")
W.Name = "Semtex"
W.Part0 = Main
W.Part1 = Obj
W.C0 = GrenadeCF:toObjectSpace(Obj.CFrame)
W.Parent = Main
end
end)
if S.TimerStartOnHit then
Detonated = true
wait(S.DetonationTime)
DetonateExplosive(Main)
end
end)
if (not S.TimerStartOnHit) then
wait(S.DetonationTime)
Detonated = true
DetonateExplosive(Main)
end
elseif S.LethalGrenadeType == 3 then
local Touched = false
Main.Touched:connect(function(Obj)
if IsIgnored(Obj) or Touched then return end
Touched = true
local W = Instance.new("Weld")
W.Name = "Sticky"
W.Part0 = Main
W.Part1 = Obj
W.C0 = Main.CFrame:toObjectSpace(Obj.CFrame)
W.Parent = Main
Main.ChildRemoved:connect(function(C)
if C.Name == "Sticky" then
local W = Instance.new("Weld")
W.Name = "Sticky"
W.Part0 = Main
W.Part1 = Obj
W.C0 = Main.CFrame:toObjectSpace(Obj.CFrame)
W.Parent = Main
end
end)
if Obj then
if Obj.Parent.ClassName == "Hat" then
local HitHumanoid = FindFirstClass(Obj.Parent.Parent, "Humanoid")
if HitHumanoid and IsEnemy(HitHumanoid) then
local CreatorTag = Instance.new("ObjectValue")
CreatorTag.Name = "creator"
CreatorTag.Value = Player
CreatorTag.Parent = HitHumanoid
HitHumanoid:TakeDamage(HitHumanoid.MaxHealth)
MarkHit()
end
else
local HitHumanoid = FindFirstClass(Obj.Parent, "Humanoid")
if HitHumanoid and IsEnemy(HitHumanoid) then
local CreatorTag = Instance.new("ObjectValue")
CreatorTag.Name = "creator"
CreatorTag.Value = Player
CreatorTag.Parent = HitHumanoid
HitHumanoid:TakeDamage(HitHumanoid.MaxHealth)
MarkHit()
end
end
end
wait(3)
Main:Destroy()
end)
end
elseif Type == 2 then
if S.TacticalGrenadeType == 1 then
if S.TimerStartOnHit then
local Detonated = false
Main.Touched:connect(function(Obj)
if IsIgnored(Obj) or Detonated then return end
Main.Velocity = Main.Velocity / 2
Detonated = true
wait(S.DetonationTime)
DetonateSmoke(Main)
end)
else
spawn(function()
local Touched = false
Main.Touched:connect(function(Obj)
if IsIgnored(Obj) or Touched then return end
Touched = true
Main.Velocity = Main.Velocity / 2
end)
end)
wait(S.DetonationTime)
DetonateSmoke(Main)
end
end
end
end)
if S.GrenadeTrail and S.GrenadeTrailTransparency ~= 1 then
spawn(function()
local LastPos = nil
while true do
if LastPos then
if (not Main:IsDescendantOf(game))
or (Main.Name == "Knife" and FindFirstClass(Main, "Weld")) then
break
end
local Trail = Instance.new("Part")
Trail.BrickColor = S.GrenadeTrailColor
Trail.Transparency = S.GrenadeTrailTransparency
Trail.Anchored = true
Trail.CanCollide = false
Trail.Size = VEC3(1, 1, 1)
local Mesh = Instance.new("BlockMesh")
Mesh.Offset = VEC3(0, 0, -(Main.Position - LastPos).magnitude / 2)
Mesh.Scale = VEC3(S.GrenadeTrailThickness, S.GrenadeTrailThickness, (Main.Position - LastPos).magnitude)
Mesh.Parent = Trail
Trail.Parent = Gun_Ignore
Trail.CFrame = CF(LastPos, Main.Position)
delay(S.GrenadeTrailVisibleTime, function()
if S.GrenadeTrailDisappearTime > 0 then
local X = 0
while true do
if X == 90 then break end
if (not Selected) then break end
local NewX = X + (1.5 / S.GrenadeTrailDisappearTime)
X = (NewX > 90 and 90 or NewX)
local Alpha = X / 90
Trail.Transparency = NumLerp(S.GrenadeTrailTransparency, 1, Alpha)
RS:wait()
end
Trail:Destroy()
else
Trail:Destroy()
end
end)
LastPos = Main.Position
else
LastPos = Main.Position
end
RS:wait()
end
end)
end
wait(0.2)
end;
function()
TweenJoint(RWeld, CF(1.5, 0, 0) * CFANG(0, 0, RAD(-10)), CF(0, 0.6, 0), Linear, 0.2)
wait(0.3)
end;
function()
Grip.Part0 = RArm
Grip.C1 = CFANG(0, RAD(20), 0)
TweenJoint(LWeld, ArmC0[1], S.ArmC1_UnAimed.Left, Linear, 0.2)
TweenJoint(RWeld, ArmC0[2], S.ArmC1_UnAimed.Right, Linear, 0.2)
wait(0.2)
end;
}
for _,F in pairs(AnimTable) do
if (not Selected) then
break
end
F()
end
if (not Selected) and Grenade0 then
Grenade0:Destroy()
end
end
|
--[=[
@return boolean
Returns `true` if the option is None.
]=]
|
function Option:IsNone()
return not self._s
end
|
--[=[
Wraps the wait()/delay() API in a promise
@class promiseWait
]=]
|
local require = require(script.Parent.loader).load(script)
local Promise = require("Promise")
return function(time)
return Promise.new(function(resolve, _)
task.delay(time, function()
resolve()
end)
end)
end
|
-- Finalize changes to parts when the handle is let go
|
Support.AddUserInputListener('Ended', 'MouseButton1', true, function (Input)
-- Make sure rotating is ongoing
if not HandleRotating then
return;
end;
-- Prevent selection
Core.Targeting.CancelSelecting();
-- Disable rotating
HandleRotating = false;
-- Clear this connection to prevent it from firing again
ClearConnection 'HandleRelease';
-- Clear change indicator states
HandleDirection = nil;
HandleFirstAngle = nil;
LastDisplayedRotation = nil;
-- Make joints, restore original anchor and collision states
for Part, State in pairs(InitialState) do
Part:MakeJoints();
Core.RestoreJoints(State.Joints);
Part.CanCollide = State.CanCollide;
Part.Anchored = State.Anchored;
end;
-- Register the change
RegisterChange();
-- Resume normal bounding box updating
BoundingBox.RecalculateStaticExtents();
BoundingBox.ResumeMonitoring();
end);
function HideHandles()
-- Hides the resizing handles
-- Make sure handles exist and are visible
if not Handles or not Handles.Visible then
return;
end;
-- Hide the handles
Handles.Visible = false;
Handles.Parent = nil;
-- Disable handle autofocus if enabled
ClearConnection 'AutofocusHandle';
end;
function RotatePartsAroundPivot(PivotMode, PivotPoint, Axis, Rotation, InitialStates)
-- Rotates the given parts in `InitialStates` around `PivotMode` (using `PivotPoint` if applicable)'s `Axis` by `Rotation`
-- Create a CFrame that increments rotation by `Rotation` around `Axis`
local RotationCFrame = CFrame.fromAxisAngle(Vector3.FromAxis(Axis), math.rad(Rotation));
-- Rotate each part
for Part, InitialState in pairs(InitialStates) do
-- Rotate around the selection's center, or the currently focused part
if PivotMode == 'Center' or PivotMode == 'Last' then
-- Calculate the focused part's rotation
local RelativeTo = PivotPoint * RotationCFrame;
-- Calculate this part's offset from the focused part's rotation
local Offset = PivotPoint:toObjectSpace(InitialState.CFrame);
-- Rotate relative to the focused part by this part's offset from it
Part.CFrame = RelativeTo * Offset;
-- Rotate around the part's center
elseif RotateTool.Pivot == 'Local' then
Part.CFrame = InitialState.CFrame * RotationCFrame;
end;
end;
end;
function GetHandleDisplayDelta(HandleRotation)
-- Returns a human-friendly version of the handle's rotation delta
-- Prepare to capture first angle
if HandleFirstAngle == nil then
HandleFirstAngle = true;
HandleDirection = true;
-- Capture first angle
elseif HandleFirstAngle == true then
-- Determine direction based on first angle
if math.abs(HandleRotation) > 180 then
HandleDirection = false;
else
HandleDirection = true;
end;
-- Disable first angle capturing
HandleFirstAngle = false;
end;
-- Determine the rotation delta to display
local DisplayedRotation;
if HandleDirection == true then
DisplayedRotation = (360 - HandleRotation) % 360;
else
DisplayedRotation = HandleRotation % 360;
end;
-- Switch delta calculation direction if crossing directions
if LastDisplayedRotation and (
(LastDisplayedRotation <= 120 and DisplayedRotation >= 240) or
(LastDisplayedRotation >= 240 and DisplayedRotation <= 120)) then
HandleDirection = not HandleDirection;
end;
-- Update displayed rotation after direction correction
if HandleDirection == true then
DisplayedRotation = (360 - HandleRotation) % 360;
else
DisplayedRotation = HandleRotation % 360;
end;
-- Store this last display rotation
LastDisplayedRotation = DisplayedRotation;
-- Return updated display delta
return DisplayedRotation;
end;
function BindShortcutKeys()
-- Enables useful shortcut keys for this tool
-- Track user input while this tool is equipped
table.insert(Connections, UserInputService.InputBegan:connect(function (InputInfo, GameProcessedEvent)
-- Make sure this is an intentional event
if GameProcessedEvent then
return;
end;
-- Make sure this input is a key press
if InputInfo.UserInputType ~= Enum.UserInputType.Keyboard then
return;
end;
-- Make sure it wasn't pressed while typing
if UserInputService:GetFocusedTextBox() then
return;
end;
-- Check if the enter key was pressed
if InputInfo.KeyCode == Enum.KeyCode.Return or InputInfo.KeyCode == Enum.KeyCode.KeypadEnter then
-- Toggle the current axis mode
if RotateTool.Pivot == 'Center' then
SetPivot('Local');
elseif RotateTool.Pivot == 'Local' then
SetPivot('Last');
elseif RotateTool.Pivot == 'Last' then
SetPivot('Center');
end;
-- Check if the - key was pressed
elseif InputInfo.KeyCode == Enum.KeyCode.Minus or InputInfo.KeyCode == Enum.KeyCode.KeypadMinus then
-- Focus on the increment input
if RotateTool.UI then
RotateTool.UI.IncrementOption.Increment.TextBox:CaptureFocus();
end;
-- Nudge around X axis if the 8 button on the keypad is pressed
elseif InputInfo.KeyCode == Enum.KeyCode.KeypadEight then
NudgeSelectionByAxis(Enum.Axis.X, 1);
-- Nudge around X axis if the 2 button on the keypad is pressed
elseif InputInfo.KeyCode == Enum.KeyCode.KeypadTwo then
NudgeSelectionByAxis(Enum.Axis.X, -1);
-- Nudge around Z axis if the 9 button on the keypad is pressed
elseif InputInfo.KeyCode == Enum.KeyCode.KeypadNine then
NudgeSelectionByAxis(Enum.Axis.Z, 1);
-- Nudge around Z axis if the 1 button on the keypad is pressed
elseif InputInfo.KeyCode == Enum.KeyCode.KeypadOne then
NudgeSelectionByAxis(Enum.Axis.Z, -1);
-- Nudge around Y axis if the 4 button on the keypad is pressed
elseif InputInfo.KeyCode == Enum.KeyCode.KeypadFour then
NudgeSelectionByAxis(Enum.Axis.Y, -1);
-- Nudge around Y axis if the 6 button on the keypad is pressed
elseif InputInfo.KeyCode == Enum.KeyCode.KeypadSix then
NudgeSelectionByAxis(Enum.Axis.Y, 1);
-- Start snapping when the R key is pressed down, and it's not the selection clearing hotkey
elseif (InputInfo.KeyCode == Enum.KeyCode.R) and not Selection.Multiselecting then
StartSnapping();
-- Start snapping when T key is pressed down (alias)
elseif InputInfo.KeyCode == Enum.KeyCode.T then
StartSnapping();
end;
end));
end;
function StartSnapping()
-- Make sure snapping isn't already enabled
if SnapTracking.Enabled then
return;
end;
-- Listen for snapped points
SnapTracking.StartTracking(function (NewPoint)
SnappedPoint = NewPoint;
end);
-- Select the snapped pivot point upon clicking
Connections.SelectSnappedPivot = Core.Mouse.Button1Down:connect(function ()
-- Disable unintentional selection
Core.Targeting.CancelSelecting();
-- Ensure there is a snap point
if not SnappedPoint then
return;
end;
-- Disable snapping
SnapTracking.StopTracking();
-- Attach the handles to a part at the snapped point
local Part = Create 'Part' {
CFrame = SnappedPoint,
Size = Vector3.new(5, 1, 5)
};
SetPivot 'Last';
AttachHandles(Part, true);
-- Maintain the part in memory to prevent garbage collection
GCBypass = { Part };
-- Set the pivot point
PivotPoint = SnappedPoint;
CustomPivotPoint = true;
-- Disconnect snapped pivot point selection listener
ClearConnection 'SelectSnappedPivot';
-- Disable custom pivot point mode when the handles attach elsewhere
DisableCustomPivotPoint = Handles.Changed:Connect(function (Property)
if Property == 'Adornee' then
CustomPivotPoint = false;
DisableCustomPivotPoint:Disconnect();
end;
end);
end);
end;
function SetAxisAngle(Axis, Angle)
-- Sets the selection's angle on axis `Axis` to `Angle`
-- Turn the given angle from degrees to radians
local Angle = math.rad(Angle);
-- Track this change
TrackChange();
-- Prepare parts to be moved
local InitialStates = PreparePartsForRotating();
-- Update each part
for Part, State in pairs(InitialStates) do
-- Set the part's new CFrame
Part.CFrame = CFrame.new(Part.Position) * CFrame.fromOrientation(
Axis == 'X' and Angle or math.rad(Part.Orientation.X),
Axis == 'Y' and Angle or math.rad(Part.Orientation.Y),
Axis == 'Z' and Angle or math.rad(Part.Orientation.Z)
);
end;
-- Cache up permissions for all private areas
local AreaPermissions = Security.GetPermissions(Security.GetSelectionAreas(Selection.Items), Core.Player);
-- Revert changes if player is not authorized to move parts to target destination
if Core.Mode == 'Tool' and Security.ArePartsViolatingAreas(Selection.Items, Core.Player, false, AreaPermissions) then
for Part, State in pairs(InitialStates) do
Part.CFrame = State.CFrame;
end;
end;
-- Restore the parts' original states
for Part, State in pairs(InitialStates) do
Part:MakeJoints();
Core.RestoreJoints(State.Joints);
Part.CanCollide = State.CanCollide;
Part.Anchored = State.Anchored;
end;
-- Register the change
RegisterChange();
end;
function NudgeSelectionByAxis(Axis, Direction)
-- Nudges the rotation of the selection in the direction of the given axis
-- Ensure selection is not empty
if #Selection.Items == 0 then
return;
end;
-- Get amount to nudge by
local NudgeAmount = RotateTool.Increment;
-- Reverse nudge amount if shift key is held while nudging
local PressedKeys = Support.FlipTable(Support.GetListMembers(UserInputService:GetKeysPressed(), 'KeyCode'));
if PressedKeys[Enum.KeyCode.LeftShift] or PressedKeys[Enum.KeyCode.RightShift] then
NudgeAmount = -NudgeAmount;
end;
-- Track the change
TrackChange();
-- Stop parts from moving, and capture the initial state of the parts
local InitialState = PreparePartsForRotating();
-- Set the pivot point to the center of the selection if in Center mode
if RotateTool.Pivot == 'Center' then
local BoundingBoxSize, BoundingBoxCFrame = BoundingBox.CalculateExtents(Selection.Items);
PivotPoint = BoundingBoxCFrame;
-- Set the pivot point to the center of the focused part if in Last mode
elseif RotateTool.Pivot == 'Last' and not CustomPivotPoint then
PivotPoint = InitialState[Selection.Focus].CFrame;
end;
-- Perform the rotation
RotatePartsAroundPivot(RotateTool.Pivot, PivotPoint, Axis, NudgeAmount * (Direction or 1), InitialState);
-- Update the "degrees rotated" indicator
if RotateTool.UI then
RotateTool.UI.Changes.Text.Text = 'rotated ' .. (NudgeAmount * (Direction or 1)) .. ' degrees';
end;
-- Cache area permissions information
local AreaPermissions = Security.GetPermissions(Security.GetSelectionAreas(Selection.Items), Core.Player);
-- Make sure we're not entering any unauthorized private areas
if Core.Mode == 'Tool' and Security.ArePartsViolatingAreas(Selection.Items, Core.Player, false, AreaPermissions) then
for Part, State in pairs(InitialState) do
Part.CFrame = State.CFrame;
end;
end;
-- Make joints, restore original anchor and collision states
for Part, State in pairs(InitialState) do
Part:MakeJoints();
Core.RestoreJoints(State.Joints);
Part.CanCollide = State.CanCollide;
Part.Anchored = State.Anchored;
end;
-- Register the change
RegisterChange();
end;
function TrackChange()
-- Start the record
HistoryRecord = {
Parts = Support.CloneTable(Selection.Items);
BeforeCFrame = {};
AfterCFrame = {};
Unapply = function (Record)
-- Reverts this change
-- Select the changed parts
Selection.Replace(Record.Parts);
-- Put together the change request
local Changes = {};
for _, Part in pairs(Record.Parts) do
table.insert(Changes, { Part = Part, CFrame = Record.BeforeCFrame[Part] });
end;
-- Send the change request
Core.SyncAPI:Invoke('SyncRotate', Changes);
end;
Apply = function (Record)
-- Applies this change
-- Select the changed parts
Selection.Replace(Record.Parts);
-- Put together the change request
local Changes = {};
for _, Part in pairs(Record.Parts) do
table.insert(Changes, { Part = Part, CFrame = Record.AfterCFrame[Part] });
end;
-- Send the change request
Core.SyncAPI:Invoke('SyncRotate', Changes);
end;
};
-- Collect the selection's initial state
for _, Part in pairs(HistoryRecord.Parts) do
HistoryRecord.BeforeCFrame[Part] = Part.CFrame;
end;
end;
function RegisterChange()
-- Finishes creating the history record and registers it
-- Make sure there's an in-progress history record
if not HistoryRecord then
return;
end;
-- Collect the selection's final state
local Changes = {};
for _, Part in pairs(HistoryRecord.Parts) do
HistoryRecord.AfterCFrame[Part] = Part.CFrame;
table.insert(Changes, { Part = Part, CFrame = Part.CFrame });
end;
-- Send the change to the server
Core.SyncAPI:Invoke('SyncRotate', Changes);
-- Register the record and clear the staging
Core.History.Add(HistoryRecord);
HistoryRecord = nil;
end;
function PreparePartsForRotating()
-- Prepares parts for rotating and returns the initial state of the parts
local InitialState = {};
-- Get index of parts
local PartIndex = Support.FlipTable(Selection.Items);
-- Stop parts from moving, and capture the initial state of the parts
for _, Part in pairs(Selection.Items) do
InitialState[Part] = { Anchored = Part.Anchored, CanCollide = Part.CanCollide, CFrame = Part.CFrame };
Part.Anchored = true;
Part.CanCollide = false;
InitialState[Part].Joints = Core.PreserveJoints(Part, PartIndex);
Part:BreakJoints();
Part.Velocity = Vector3.new();
Part.RotVelocity = Vector3.new();
end;
return InitialState;
end;
function GetIncrementMultiple(Number, Increment)
-- Get how far the actual distance is from a multiple of our increment
local MultipleDifference = Number % Increment;
-- Identify the closest lower and upper multiples of the increment
local LowerMultiple = Number - MultipleDifference;
local UpperMultiple = Number - MultipleDifference + Increment;
-- Calculate to which of the two multiples we're closer
local LowerMultipleProximity = math.abs(Number - LowerMultiple);
local UpperMultipleProximity = math.abs(Number - UpperMultiple);
-- Use the closest multiple of our increment as the distance moved
if LowerMultipleProximity <= UpperMultipleProximity then
Number = LowerMultiple;
else
Number = UpperMultiple;
end;
return Number;
end;
|
--[[ @brief Reshuffles the heap if a given index is larger than one of its children.
--]]
|
function Heap:_HeapifyTopDown(i)
local l = i * 2;
local r = l + 1;
local largest;
if l <= #self and self.Comparator(self[l], self[i]) then
largest = l;
else
largest = i;
end
if r <= #self and self.Comparator(self[r], self[largest]) then
largest = r;
end
if largest ~= i then
self[i], self[largest] = self[largest], self[i];
self:_HeapifyTopDown(largest);
end
end
|
-------------------------
|
function DoorClose()
if Shaft00.MetalDoor.CanCollide == false then
Shaft00.MetalDoor.CanCollide = true
while Shaft00.MetalDoor.Transparency > 0.0 do
Shaft00.MetalDoor.Transparency = Shaft00.MetalDoor.Transparency - .1
wait(0.000001)
end
Car.BodyVelocity.velocity = Vector3.new(0, 20, 0) --Change 10 to change the speed.
end
if Shaft01.MetalDoor.CanCollide == false then
Shaft01.MetalDoor.CanCollide = true
while Shaft01.MetalDoor.Transparency > 0.0 do
Shaft01.MetalDoor.Transparency = Shaft01.MetalDoor.Transparency - .1
wait(0.000001)
end
Car.BodyVelocity.velocity = Vector3.new(0, 20, 0)
end
if Shaft02.MetalDoor.CanCollide == false then
Shaft02.MetalDoor.CanCollide = true
while Shaft02.MetalDoor.Transparency > 0.0 do
Shaft02.MetalDoor.Transparency = Shaft02.MetalDoor.Transparency - .1
wait(0.000001)
end
Car.BodyVelocity.velocity = Vector3.new(0, 20, 0)
end
if Shaft03.MetalDoor.CanCollide == false then
Shaft03.MetalDoor.CanCollide = true
while Shaft03.MetalDoor.Transparency > 0.0 do
Shaft03.MetalDoor.Transparency = Shaft03.MetalDoor.Transparency - .1
wait(0.000001)
end
Car.BodyVelocity.velocity = Vector3.new(0, 20, 0)
end
if Shaft04.MetalDoor.CanCollide == false then
Shaft04.MetalDoor.CanCollide = true
while Shaft04.MetalDoor.Transparency > 0.0 do
Shaft04.MetalDoor.Transparency = Shaft04.MetalDoor.Transparency - .1
wait(0.000001)
end
Car.BodyVelocity.velocity = Vector3.new(0, 20, 0)
end
if Shaft05.MetalDoor.CanCollide == false then
Shaft05.MetalDoor.CanCollide = true
while Shaft05.MetalDoor.Transparency > 0.0 do
Shaft05.MetalDoor.Transparency = Shaft05.MetalDoor.Transparency - .1
wait(0.000001)
end
Car.BodyVelocity.velocity = Vector3.new(0, 20, 0)
end
if Shaft06.MetalDoor.CanCollide == false then
Shaft06.MetalDoor.CanCollide = true
while Shaft06.MetalDoor.Transparency > 0.0 do
Shaft06.MetalDoor.Transparency = Shaft06.MetalDoor.Transparency - .1
wait(0.000001)
end
end
if Shaft07.MetalDoor.CanCollide == false then
Shaft07.MetalDoor.CanCollide = true
while Shaft07.MetalDoor.Transparency > 0.0 do
Shaft07.MetalDoor.Transparency = Shaft07.MetalDoor.Transparency - .1
wait(0.000001)
end
Car.BodyVelocity.velocity = Vector3.new(0, -20, 0)
end
if Shaft08.MetalDoor.CanCollide == false then
Shaft08.MetalDoor.CanCollide = true
while Shaft08.MetalDoor.Transparency > 0.0 do
Shaft08.MetalDoor.Transparency = Shaft08.MetalDoor.Transparency - .1
wait(0.000001)
end
Car.BodyVelocity.velocity = Vector3.new(0, -20, 0)
end
if Shaft09.MetalDoor.CanCollide == false then
Shaft09.MetalDoor.CanCollide = true
while Shaft09.MetalDoor.Transparency > 0.0 do
Shaft09.MetalDoor.Transparency = Shaft09.MetalDoor.Transparency - .1
wait(0.000001)
end
Car.BodyVelocity.velocity = Vector3.new(0, -20, 0)
end
if Shaft10.MetalDoor.CanCollide == false then
Shaft10.MetalDoor.CanCollide = true
while Shaft10.MetalDoor.Transparency > 0.0 do
Shaft10.MetalDoor.Transparency = Shaft10.MetalDoor.Transparency - .1
wait(0.000001)
end
Car.BodyVelocity.velocity = Vector3.new(0, -20, 0)
end
if Shaft11.MetalDoor.CanCollide == false then
Shaft11.MetalDoor.CanCollide = true
while Shaft11.MetalDoor.Transparency > 0.0 do
Shaft11.MetalDoor.Transparency = Shaft11.MetalDoor.Transparency - .1
wait(0.000001)
end
Car.BodyVelocity.velocity = Vector3.new(0, -20, 0)
end
if Shaft12.MetalDoor.CanCollide == false then
Shaft12.MetalDoor.CanCollide = true
while Shaft12.MetalDoor.Transparency > 0.0 do
Shaft12.MetalDoor.Transparency = Shaft12.MetalDoor.Transparency - .1
wait(0.000001)
end
Car.BodyVelocity.velocity = Vector3.new(0, -20, 0)
end
if Shaft13.MetalDoor.CanCollide == false then
Shaft13.MetalDoor.CanCollide = true
while Shaft13.MetalDoor.Transparency > 0.0 do
Shaft13.MetalDoor.Transparency = Shaft13.MetalDoor.Transparency - .1
wait(0.000001)
end
Car.BodyVelocity.velocity = Vector3.new(0, -20, 0)
end
end
function onClicked()
DoorClose()
end
script.Parent.MouseButton1Click:connect(onClicked)
script.Parent.MouseButton1Click:connect(function()
if clicker == true
then clicker = false
else
return
end
end)
script.Parent.MouseButton1Click:connect(function()
Car.Touched:connect(function(otherPart)
if otherPart == Elevator.Floors:FindFirstChild(script.Parent.Name)
then StopE() DoorOpen()
end
end)end)
function StopE()
Car.BodyVelocity.velocity = Vector3.new(0, 0, 0)
Car.BodyPosition.position = Elevator.Floors:FindFirstChild(script.Parent.Name).Position
clicker = true
end
function DoorOpen()
while Shaft06.MetalDoor.Transparency < 1.0 do
Shaft06.MetalDoor.Transparency = Shaft06.MetalDoor.Transparency + .1
wait(0.000001)
end
Shaft06.MetalDoor.CanCollide = false
end
|
--[=[
@param defaultFn () -> any
@return value: any
If the option holds a value, returns the value. Otherwise, returns the
result of the `defaultFn` function.
]=]
|
function Option:UnwrapOrElse(defaultFn)
if self:IsSome() then
return self:Unwrap()
else
return defaultFn()
end
end
|
--------------------------------------------------------------------------
|
local _WHEELTUNE = {
--[[
SS6 Presets
[Eco]
WearSpeed = 1,
TargetFriction = .7,
MinFriction = .1,
[Road]
WearSpeed = 2,
TargetFriction = .7,
MinFriction = .1,
[Sport]
WearSpeed = 3,
TargetFriction = .79,
MinFriction = .1, ]]
TireWearOn = true ,
--Friction and Wear
FWearSpeed = 3 ,
FTargetFriction = .5 ,
FMinFriction = .1 ,
RWearSpeed = 3 ,
RTargetFriction = .5 ,
RMinFriction = .1 ,
--Tire Slip
TCSOffRatio = 1/3 ,
WheelLockRatio = 1/2 , --SS6 Default = 1/4
WheelspinRatio = 1/1.1 , --SS6 Default = 1/1.2
--Wheel Properties
FFrictionWeight = 1 , --SS6 Default = 1
RFrictionWeight = 1 , --SS6 Default = 1
FLgcyFrWeight = 10 ,
RLgcyFrWeight = 10 ,
FElasticity = .5 , --SS6 Default = .5
RElasticity = .5 , --SS6 Default = .5
FLgcyElasticity = 0 ,
RLgcyElasticity = 0 ,
FElastWeight = 1 , --SS6 Default = 1
RElastWeight = 1 , --SS6 Default = 1
FLgcyElWeight = 10 ,
RLgcyElWeight = 10 ,
--Wear Regen
RegenSpeed = 3.6 --SS6 Default = 3.6
}
|
-- Welcome to the variable museum:
|
local player = script.Parent.Parent.Parent
local plane,mainParts,animationParts,info,main,move,gryo,seat,landingGear,accel,canCrash,crashForce,crashSpin,crashVisual,maxBank,maxSpeed,speedVary,stallSpeed,throttleInc,altRestrict,altMin,altMax,altSet
local desiredSpeed,currentSpeed,realSpeed = 0,0,0
local mouseSave
local gearParts = {}
local selected,flying,on,dead,gear,throttle = false,false,false,false,true,0
local gui = script.Parent.PlaneGui:clone()
local panel = gui.Panel
local lowestPoint = 0
local A = math.abs -- Creating a shortcut for the function
local keys = {
engine={key};
landing = {key};
spdup={byte=0;down=false};
spddwn={byte=0;down=false};
}
function waitFor(parent,array) -- Backup system to wait for objects to 'load'
if (array) then
for _,name in pairs(array) do
while (not parent:findFirstChild(name)) do wait() end -- If the object is found right away, no time will be spent waiting. That's why 'while' loops work better than 'repeat' in this case
end
elseif (parent:IsA("ObjectValue")) then
while (not parent.Value) do wait() end
end
end
function fixVars() -- Correct your mistakes to make sure the plane still flies correctly!
maxBank = (maxBank < -90 and -90 or maxBank > 90 and 90 or maxBank)
throttleInc = (throttleInc < 0.01 and 0.01 or throttleInc > 1 and 1 or throttleInc)
stallSpeed = (stallSpeed > maxSpeed and maxSpeed or stallSpeed)
accel = (accel < 0.01 and 0.01 or accel > maxSpeed and maxSpeed or accel)
altMax = ((altMax-100) < altMin and (altMin+100) or altMax)
altMax = (altSet and (altMax+main.Position.y) or altMax)
altMin = (altSet and (altMin+main.Position.y) or altMin)
keys.engine.key = (keys.engine.key == "" and "e" or keys.engine.key)
keys.spdup.byte = (keys.spdup.byte == 0 and 17 or keys.spdup.byte)
keys.spddwn.byte = (keys.spddwn.byte == 0 and 18 or keys.spddwn.byte)
keys.landing.key = (keys.landing.key == "" and "g" or keys.landing.key)
end
function getVars() -- Since this plane kit is supposed to make you avoid scripting altogether, I have to go the extra mile and write a messy function to account for all those object variables
plane = script.Parent.Plane.Value
waitFor(plane,{"MainParts","OtherParts","AnimationParts","EDIT_THESE","Dead"})
mainParts,info = plane.MainParts,plane.EDIT_THESE
animationParts = plane.AnimationParts
waitFor(mainParts,{"Main","MainSeat","LandingGear"})
main,seat,landingGear = mainParts.Main,mainParts.MainSeat,mainParts.LandingGear
waitFor(main,{"Move","Gyro"})
move,gyro = main.Move,main.Gyro
accel,canCrash,crashForce,crashSpin,crashVisual,maxBank,maxSpeed,speedVary,stallSpeed,throttleInc,altRestrict,altMin,altMax,altSet = -- Quickest way to assign tons of variables
A(info.Acceleration.Value),info.CanCrash.Value,A(info.CanCrash.Force.Value),info.CanCrash.SpinSpeed.Value,info.CanCrash.VisualFX.Value,
info.MaxBank.Value,A(info.MaxSpeed.Value),A(info.SpeedDifferential.Value),A(info.StallSpeed.Value),A(info.ThrottleIncrease.Value),
info.AltitudeRestrictions.Value,info.AltitudeRestrictions.MinAltitude.Value,info.AltitudeRestrictions.MaxAltitude.Value,info.AltitudeRestrictions.SetByOrigin.Value
keys.engine.key = info.Hotkeys.Engine.Value:gmatch("%a")():lower()
keys.landing.key = info.Hotkeys.Gear.Value:gmatch("%a")():lower()
local sU,sD = info.Hotkeys.SpeedUp.Value:lower(),info.Hotkeys.SpeedDown.Value:lower()
keys.spdup.byte = (sU == "arrowkeyup" and 17 or sU == "arrowkeydown" and 18 or sU:gmatch("%a")():byte()) -- Ternary operations use logical figures to avoid 'if' statements
keys.spddwn.byte = (sD == "arrowkeyup" and 17 or sD == "arrowkeydown" and 18 or sD:gmatch("%a")():byte())
fixVars()
plane.Dead.Changed:connect(function()
if ((plane.Dead.Value) and (not dead)) then -- DIE!
dead,flying,on = true,false,false
main.Fire.Enabled,main.Smoke.Enabled = info.CanCrash.VisualFX.Value,info.CanCrash.VisualFX.Value
move.maxForce = Vector3.new(0,0,0)
gyro.D = 1e3
while ((selected) and (not plane.Dead.Stop.Value)) do
gyro.cframe = (gyro.cframe*CFrame.Angles(0,0,math.rad(crashSpin)))
wait()
end
end
end)
end
function getGear(parent) -- Very common way to scan through every descendant of a model:
for _,v in pairs(parent:GetChildren()) do
if (v:IsA("BasePart")) then
local t,r,c = Instance.new("NumberValue",v),Instance.new("NumberValue",v),Instance.new("BoolValue",v) -- Saving original properties
t.Name,r.Name,c.Name = "Trans","Ref","Collide"
t.Value,r.Value,c.Value = v.Transparency,v.Reflectance,v.CanCollide
table.insert(gearParts,v)
end
getGear(v)
end
end
function getLowestPoint() -- Plane will use LowestPoint to determine where to look to make sure the plane is either flying or on the ground
if (#gearParts == 0) then
lowestPoint = (main.Position.y+5+(main.Size.y/2))
return
end
for _,v in pairs(gearParts) do -- Not very efficient, but it basically does what I designed it to do:
local _0 = (main.Position.y-(v.CFrame*CFrame.new((v.Size.x/2),0,0)).y)
local _1 = (main.Position.y-(v.CFrame*CFrame.new(-(v.Size.x/2),0,0)).y)
local _2 = (main.Position.y-(v.CFrame*CFrame.new(0,(v.Size.y/2),0)).y)
local _3 = (main.Position.y-(v.CFrame*CFrame.new(0,-(v.Size.y/2),0)).y)
local _4 = (main.Position.y-(v.CFrame*CFrame.new(0,0,(v.Size.z/2))).y)
local _5 = (main.Position.y-(v.CFrame*CFrame.new(0,0,-(v.Size.z/2))).y)
local n = (math.max(_0,_1,_2,_3,_4,_5)+5)
lowestPoint = (n > lowestPoint and n or lowestPoint)
end
end
function guiSetup() -- Setting up the GUI buttons and such
local cur = 0
panel.Controls.Position = UDim2.new(0,0,0,-(panel.Controls.AbsolutePosition.y+panel.Controls.AbsoluteSize.y))
panel.ControlsButton.MouseButton1Click:connect(function()
cur = (cur == 0 and 1 or 0)
if (cur == 0) then
panel.Controls:TweenPosition(UDim2.new(0,0,0,-(panel.Controls.AbsolutePosition.y+panel.Controls.AbsoluteSize.y)),"In","Sine",0.35)
else
panel.Controls.Visible = true
panel.Controls:TweenPosition(UDim2.new(0,0,1.5,0),"Out","Back",0.5)
end
end)
panel.Controls.C1.Text = (keys.engine.key:upper() .. " Key")
panel.Controls.C2.Text = (keys.spdup.byte == 17 and "UP Arrow Key" or keys.spdup.byte == 18 and "DOWN Arrow Key" or (string.char(keys.spdup.byte):upper() .. " Key"))
panel.Controls.C3.Text = (keys.spddwn.byte == 17 and "UP Arrow Key" or keys.spddwn.byte == 18 and "DOWN Arrow Key" or (string.char(keys.spddwn.byte):upper() .. " Key"))
panel.Controls.C4.Text = (keys.landing.key:upper() .. " Key")
end
waitFor(script.Parent,{"Plane","Deselect0","Deselect1","CurrentSelect"})
waitFor(script.Parent.Plane)
getVars()
getGear(landingGear)
getLowestPoint()
guiSetup()
if (script.Parent.Active) then
script.Parent.Name = "RESELECT"
while (script.Parent.Active) do wait() end
end
script.Parent.Name = "Plane"
function changeGear()
gear = (not gear)
for _,v in pairs(gearParts) do
v.Transparency,v.Reflectance,v.CanCollide = (gear and v.Trans.Value or 1),(gear and v.Ref.Value or 0),(gear and v.Collide.Value or false) -- Learning how to code like this is extremely useful
end
end
function updateGui(taxiing,stalling)
panel.Off.Visible = (not on)
panel.Taxi.Visible,panel.Stall.Visible = taxiing,(not taxiing and stalling)
if ((realSpeed > -10000) and (realSpeed < 10000)) then
panel.Speed.Value.Text = tostring(math.floor(realSpeed+0.5))
end
panel.Altitude.Value.Text = tostring(math.floor(main.Position.y+0.5))
panel.Throttle.Bar.Amount.Size = UDim2.new(throttle,0,1,0)
end
function taxi() -- Check to see if the plane is on the ground or not
return (currentSpeed <= stallSpeed and game.Workspace:findPartOnRay(Ray.new(main.Position,Vector3.new(0,-lowestPoint,0)),plane)) -- Make sure plane is on a surface
end
function stall() -- Originally set as a giant ternary operation, but got WAY too complex, so I decided to break it down for my own sanity
if ((altRestrict) and (main.Position.y > altMax)) then return true end
local diff = ((realSpeed-stallSpeed)/200)
diff = (diff > 0.9 and 0.9 or diff)
local check = { -- Table placed here so I could easily add new 'checks' at ease. If anything in this table is 'true,' then the plane will be considered to be taxiing
(currentSpeed <= stallSpeed);
(main.CFrame.lookVector.y > (realSpeed < stallSpeed and -1 or -diff));
}
for _,c in pairs(check) do
if (not c) then return false end
end
return true
end
function fly(m) -- Main function that controls all of the flying stuff. Very messy.
flying = true
local pos,t = main.Position,time()
local lastStall = false
while ((flying) and (not dead)) do
--realSpeed = ((pos-main.Position).magnitude/(time()-t)) -- Calculate "real" speed
realSpeed = main.Velocity.Magnitude
pos,t = main.Position,time()
local max = (maxSpeed+(-main.CFrame.lookVector.y*speedVary)) -- Speed variety based on the pitch of the aircraft
desiredSpeed = (max*(on and throttle or 0)) -- Find speed based on throttle
local change = (desiredSpeed > currentSpeed and 1 or -1) -- Decide between accelerating or decelerating
currentSpeed = (currentSpeed+(accel*change)) -- Calculate new speed
|
--[[
-- Чтение построек в игроке
-- Изменение и сохранение тут (точней на автомате меняется таблица объектов построек игрока)
]]
|
build = {}
|
--[[ By: Brutez. Script Fixed By Xcorrectgamermaster ]]
|
--
local PlayerSpawning=false; --[[ Change this to true if you want the NPC to spawn like a player, and change this to false if you want the NPC to spawn at it's current position. ]]--
local AdvancedRespawnScript=script;
repeat wait(0)until script and script.Parent and script.Parent.ClassName=="Model";
local JeffTheKiller=AdvancedRespawnScript.Parent;
local GameDerbis=game:GetService("Debris");
local JeffTheKillerHumanoid;
for _,Child in pairs(JeffTheKiller:GetChildren())do
if Child and Child.ClassName=="Humanoid"and Child.Health~=0 then
JeffTheKillerHumanoid=Child;
end;
end;
local Respawndant=JeffTheKiller:Clone();
if PlayerSpawning then --[[ LOOK AT LINE: 2. ]]--
coroutine.resume(coroutine.create(function()
if JeffTheKiller and JeffTheKillerHumanoid and JeffTheKillerHumanoid:FindFirstChild("Status")and not JeffTheKillerHumanoid:FindFirstChild("Status"):FindFirstChild("AvalibleSpawns")then
SpawnModel=Instance.new("Model");
SpawnModel.Parent=JeffTheKillerHumanoid.Status;
SpawnModel.Name="AvalibleSpawns";
else
SpawnModel=JeffTheKillerHumanoid:FindFirstChild("Status"):FindFirstChild("AvalibleSpawns");
end;
function FindSpawn(SearchValue)
local PartsArchivable=SearchValue:GetChildren();
for AreaSearch=1,#PartsArchivable do
if PartsArchivable[AreaSearch].className=="SpawnLocation"then
local PositionValue=Instance.new("Vector3Value",SpawnModel);
PositionValue.Value=PartsArchivable[AreaSearch].Position;
PositionValue.Name=PartsArchivable[AreaSearch].Duration;
end;
FindSpawn(PartsArchivable[AreaSearch]);
end;
end;
FindSpawn(game:GetService("Workspace"));
local SpawnChilden=SpawnModel:GetChildren();
if#SpawnChilden>0 then
local SpawnItself=SpawnChilden[math.random(1,#SpawnChilden)];
local RespawningForceField=Instance.new("ForceField");
RespawningForceField.Parent=JeffTheKiller;
RespawningForceField.Name="SpawnForceField";
GameDerbis:AddItem(RespawningForceField,SpawnItself.Name);
JeffTheKiller:MoveTo(SpawnItself.Value+Vector3.new(0,3.5,0));
else
if JeffTheKiller:FindFirstChild("SpawnForceField")then
JeffTheKiller:FindFirstChild("SpawnForceField"):Destroy();
end;
JeffTheKiller:MoveTo(Vector3.new(0,115,0));
end;
end));
end;
function Respawn()
wait(10);
Respawndant.Parent=JeffTheKiller.Parent;
Respawndant:makeJoints();
Respawndant:FindFirstChild("Head"):MakeJoints();
Respawndant:FindFirstChild("Torso"):MakeJoints();
JeffTheKiller:remove();
end;
if AdvancedRespawnScript and JeffTheKiller and JeffTheKillerHumanoid then
JeffTheKillerHumanoid.Died:Connect(Respawn);
end;
|
-- A simple function to explode a specified part
|
function Explode(part)
local explosion = Instance.new("Explosion", workspace)
explosion.Position = part.Position
explosion.BlastRadius = config.ExplosionRadius.Value
part:Destroy()
end
script.Parent.Throw.OnServerEvent:connect(function(player, mousePosition)
local handlePos = Vector3.new(tool.Handle.Position.X, 0, tool.Handle.Position.Z) -- remove Y from the equation, it's not needed
local mousePos = Vector3.new(mousePosition.X, 0, mousePosition.Z) -- ditto
local distance = (handlePos - mousePos).magnitude -- Get the distance between the handle and the mouse
local altitude = mousePosition.Y - tool.Handle.Position.Y
local angle = AngleOfReach(distance, altitude, config.GrenadeVelocity.Value) -- Calculate the angle
tool.Handle.Transparency = 1
local grenade = tool.Handle:Clone()
grenade.Parent = workspace
grenade.Transparency = 0
grenade.CanCollide = true
grenade.CFrame = tool.Handle.CFrame
grenade.Velocity = (CFrame.new(grenade.Position, Vector3.new(mousePosition.X, grenade.Position.Y, mousePosition.Z)) * CFrame.Angles(angle, 0, 0)).lookVector * config.GrenadeVelocity.Value -- Throwing 'n stuff, it probably didn't need to be this long
spawn(function()
if config.ExplodeOnTouch.Value then
grenade.Touched:connect(function(hit)
if hit.Parent ~= tool.Parent and hit.CanCollide then -- Make sure what we're hitting is collidable
Explode(grenade)
end
end)
else
wait(config.FuseTime.Value)
Explode(grenade)
end
end)
wait(config.Cooldown.Value)
tool.Handle.Transparency = 0
end)
|
--connection
|
function onSelected(mouse)
local c = game.Players.LocalPlayer:GetChildren()
for i = 1,#c do
if c[i].className == "Message" or c[i].className == "Hint" then
c[i]:Remove()
end
end
if (punchload == false) then mouse.Icon = "rbxasset://textures\\GunCursor.png" end
if (punchload == true) then mouse.Icon = "rbxasset://textures\\GunWaitCursor.png" end
mouse.Button1Down:connect(function() FalconPUUUNCH(mouse) end)
end
bin.Selected:connect(onSelected)
|
--[=[
Gets the default pseudo locale string.
@return string
]=]
|
function PseudoLocalize.getDefaultPseudoLocaleId()
return DEFAULT_PSEUDO_LOCALE_ID
end
|
-- Created by Quenty
|
wait(1)
local Configuration = {
MaxSpeed = 30;
Acceleration = 5; -- Will always be a little bit less than this because ROBLOX characters will add mass. Also, friction.
MaxRotationCorrectionAcceleration = math.pi/40; -- I wouldn't touch this.
-- math.pi/10 -- Correct for 18 degrees every.... second?
PercentExtraCargo = 0.005; -- Compared to boat's mass (weight), how much extra cargo can it support (irncludes characters) before it starts sinking.
TurnAccelerationFactor = 150; -- E_e No idea why this is 500.
MaxTurnSpeed = 2.5; -- RotVelocity will probably never get to this.
MaxShipTiltInRadians = math.pi/8;
TiltRatioFactor = 0.01; -- Don't touch this. Used because the BodyAngularVelocity "can't even" when it comes to reaching desired velocity.
AmplitudeOfWaves = 2.5; -- How far up/down the boat moves in the waves. (Amplitude, so if you physics, you realize it can move this magnitude away from the starting point, either up, or down).
MaxShipYawInRadians = math.pi/120; -- Yaws in the waves
AddedYawOnSpeed = math.pi/80;
WaterLevel = 39;
}
local function WaitForChild(Parent, Name, TimeLimit)
-- Waits for a child to appear. Not efficient, but it shoudln't have to be. It helps with debugging.
-- Useful when ROBLOX lags out, and doesn't replicate quickly.
-- @param TimeLimit If TimeLimit is given, then it will return after the timelimit, even if it hasn't found the child.
assert(Parent ~= nil, "Parent is nil")
assert(type(Name) == "string", "Name is not a string.")
local Child = Parent:FindFirstChild(Name)
local StartTime = tick()
local Warned = false
while not Child and Parent do
wait(0)
Child = Parent:FindFirstChild(Name)
if not Warned and StartTime + (TimeLimit or 5) <= tick() then
Warned = true
warn("Infinite yield possible for WaitForChild(" .. Parent:GetFullName() .. ", " .. Name .. ")")
if TimeLimit then
return Parent:FindFirstChild(Name)
end
end
end
if not Parent then
warn("Parent became nil.")
end
return Child
end
local function Modify(Instance, Values)
-- Modifies an Instance by using a table.
for Index, Value in next, Values do
if type(Index) == "number" then
Value.Parent = Instance
else
Instance[Index] = Value
end
end
return Instance
end
local function Make(ClassType, Properties)
-- Using a syntax hack to create a nice way to Make new items.
return Modify(Instance.new(ClassType), Properties)
end
local Signal = {}
function Signal.new()
local sig = {}
local mSignaler = Instance.new('BindableEvent')
local mArgData = nil
local mArgDataCount = nil
function sig:fire(...)
mArgData = {...}
mArgDataCount = select('#', ...)
mSignaler:Fire()
end
function sig:connect(f)
if not f then error("connect(nil)", 2) end
return mSignaler.Event:connect(function()
f(unpack(mArgData, 1, mArgDataCount))
end)
end
function sig:wait()
mSignaler.Event:wait()
assert(mArgData, "Missing arg data, likely due to :TweenSize/Position corrupting threadrefs.")
return unpack(mArgData, 1, mArgDataCount)
end
return sig
end
local function WeldTogether(Part0, Part1, JointType, WeldParent)
--- Weld's 2 parts together
-- @param Part0 The first part
-- @param Part1 The second part (Dependent part most of the time).
-- @param [JointType] The type of joint. Defaults to weld.
-- @param [WeldParent] Parent of the weld, Defaults to Part0 (so GC is better).
-- @return The weld created.
JointType = JointType or "Weld"
local NewWeld = Make(JointType, {
Part0 = Part0;
Part1 = Part1;
C0 = CFrame.new();--Part0.CFrame:inverse();
C1 = Part1.CFrame:toObjectSpace(Part0.CFrame); --Part1.CFrame:inverse() * Part0.CFrame;-- Part1.CFrame:inverse();
Parent = WeldParent or Part0;
})
return NewWeld
end
local function WeldParts(Parts, MainPart, JointType, DoNotUnanchor)
-- @param Parts The Parts to weld. Should be anchored to prevent really horrible results.
-- @param MainPart The part to weld the model to (can be in the model).
-- @param [JointType] The type of joint. Defaults to weld.
-- @parm DoNotUnanchor Boolean, if true, will not unachor the model after cmopletion.
for _, Part in pairs(Parts) do
WeldTogether(MainPart, Part, JointType, MainPart)
end
if not DoNotUnanchor then
for _, Part in pairs(Parts) do
Part.Anchored = false
end
MainPart.Anchored = false
end
end
local function CallOnChildren(Instance, FunctionToCall)
-- Calls a function on each of the children of a certain object, using recursion.
FunctionToCall(Instance)
for _, Child in next, Instance:GetChildren() do
CallOnChildren(Child, FunctionToCall)
end
end
local function GetBricks(StartInstance)
local List = {}
-- if StartInstance:IsA("BasePart") then
-- List[#List+1] = StartInstance
-- end
CallOnChildren(StartInstance, function(Item)
if Item:IsA("BasePart") then
List[#List+1] = Item;
end
end)
return List;
end
local function GetBricksWithIgnoreFunction(StartInstance, DoIgnore)
--- Get's the bricks in a model, but will not get a brick that is "NoInclude"
local List = {}
CallOnChildren(StartInstance, function(Item)
if Item:IsA("BasePart") and not DoIgnore(Item) then
List[#List+1] = Item
end
end)
return List
end
local function GetCharacter(Descendant)
-- Returns the Player and Charater that a descendent is part of, if it is part of one.
-- @param Descendant A child of the potential character.
local Charater = Descendant
local Player = Players:GetPlayerFromCharacter(Charater)
while not Player do
if Charater.Parent then
Charater = Charater.Parent
Player = Players:GetPlayerFromCharacter(Charater)
else
return nil
end
end
return Charater, Player
end
local MakeMaid do
local index = {
GiveTask = function(self,task)
local n = #self.Tasks+1
self.Tasks[n] = task
return n
end;
DoCleaning = function(self)
local tasks = self.Tasks
for name,task in pairs(tasks) do
if type(task) == 'function' then
task()
else
task:disconnect()
end
tasks[name] = nil
end
-- self.Tasks = {}
end;
};
local mt = {
__index = function(self,k)
if index[k] then
return index[k]
else
return self.Tasks[k]
end
end;
__newindex = function(self,k,v)
local tasks = self.Tasks
if v == nil then
-- disconnect if the task is an event
if type(tasks[k]) ~= 'function' then
tasks[k]:disconnect()
end
elseif tasks[k] then
-- clear previous task
self[k] = nil
end
tasks[k] = v
end;
}
function MakeMaid()
return setmetatable({Tasks={},Instances={}},mt)
end
end
local function CheckPlayer(Player)
--- Makes sure a player has all necessary components.
-- @return Boolean If the player has all the right components
return Player and Player:IsA("Player")
end
local function CheckCharacter(Player)
-- Makes sure a character has all the right "parts"
if CheckPlayer(Player) then
local Character = Player.Character;
if Character then
return Character.Parent
and Character:FindFirstChild("Humanoid")
and Character:FindFirstChild("HumanoidRootPart")
and Character:FindFirstChild("Torso")
and Character:FindFirstChild("Head")
and Character.Humanoid:IsA("Humanoid")
and Character.Head:IsA("BasePart")
and Character.Torso:IsA("BasePart")
and true
end
else
print("[CheckCharacter] - Character Check failed!")
end
return nil
end
local function GetCenterOfMass(Parts)
--- Return's the world vector center of mass.
-- Lots of help from Hippalectryon :D
local TotalMass = 0
local SumOfMasses = Vector3.new(0, 0, 0)
for _, Part in pairs(Parts) do
-- Part.BrickColor = BrickColor.new("Bright yellow")
TotalMass = TotalMass + Part:GetMass()
SumOfMasses = SumOfMasses + Part:GetMass() * Part.Position
end
-- print("Sum of masses: " .. tostring(SumOfMasses))
-- print("Total mass: " .. tostring(TotalMass))
return SumOfMasses/TotalMass, TotalMass
end
|
--[[
timer = Timer.new(interval: number [, janitor: Janitor])
connection = Timer.Simple(interval: number, callback: () -> void [, updateSignal: Signal = Heartbeat, timeFunc: () -> number = time])
timer.Tick: Signal
timer.Interval: number
timer.UpdateSignal: Signal
timer.TimeFunction: () -> number
timer.AllowDrift: boolean
timer:Start()
timer:StartNow()
timer:Stop()
timer:Destroy()
------------------------------------
local timer = Timer.new(2)
timer.Tick:Connect(function()
print("Tock")
end)
timer:Start()
Timer.Simple(2, function()
print("Tock")
end)
--]]
|
type CallbackFunc = () -> nil
type TimeFunc = () -> number
local Signal = require(script.Parent.Signal)
local RunService = game:GetService("RunService")
local Timer = {}
Timer.__index = Timer
function Timer.new(interval: number, janitor)
assert(type(interval) == "number", "Argument #1 to Timer.new must be a number; got " .. type(interval))
assert(interval >= 0, "Argument #1 to Timer.new must be greater or equal to 0; got " .. tostring(interval))
local self = setmetatable({}, Timer)
self._runHandle = nil
self.Interval = interval
self.UpdateSignal = RunService.Heartbeat
self.TimeFunction = time
self.AllowDrift = true
self.Tick = Signal.new()
if janitor then
janitor:Add(self)
end
return self
end
function Timer.Simple(interval: number, callback: CallbackFunc, startNow: boolean?, updateSignal: RBXScriptSignal?, timeFunc: TimeFunc?)
local update = updateSignal or RunService.Heartbeat
local t = timeFunc or time
local nextTick = t() + interval
if startNow then
task.defer(callback)
end
return update:Connect(function()
local now = t()
if now >= nextTick then
nextTick = now + interval
task.defer(callback)
end
end)
end
function Timer.Is(obj: any): boolean
return type(obj) == "table" and getmetatable(obj) == Timer
end
function Timer:_startTimer()
local t = self.TimeFunction
local nextTick = t() + self.Interval
self._runHandle = self.UpdateSignal:Connect(function()
local now = t()
if now >= nextTick then
nextTick = now + self.Interval
self.Tick:Fire()
end
end)
end
function Timer:_startTimerNoDrift()
assert(self.Interval > 0, "Interval must be greater than 0 when AllowDrift is set to false")
local t = self.TimeFunction
local n = 1
local start = t()
local nextTick = start + self.Interval
self._runHandle = self.UpdateSignal:Connect(function()
local now = t()
while now >= nextTick do
n += 1
nextTick = start + (self.Interval * n)
self.Tick:Fire()
end
end)
end
function Timer:Start()
if self._runHandle then return end
if self.AllowDrift then
self:_startTimer()
else
self:_startTimerNoDrift()
end
end
function Timer:StartNow()
if self._runHandle then return end
self.Tick:Fire()
self:Start()
end
function Timer:Stop()
if not self._runHandle then return end
self._runHandle:Disconnect()
self._runHandle = nil
end
function Timer:Destroy()
self.Tick:Destroy()
self:Stop()
end
return Timer
|
--[[
This loads HD Admin into your game.
Require the 'HD Admin MainModule' by the HD Admin group for automatic updates.
You can view the HD Admin Main Module here:
https://www.roblox.com/library/3239236979/HD
--]]
|
local loaderFolder = script.Parent.Parent
local mainModule = require(3239236979)
mainModule:Initialize(loaderFolder)
loaderFolder:Destroy()
|
--[Funkcje]
|
function onClicked()
if legansio == true then
sl7.Material = "Plastic"
sp7.Material = "Plastic"
sl7.SurfaceLight.Enabled = false
sp7.SurfaceLight.Enabled = false
wait(2)
sp7.Transparency = 1
sl7.Transparency = 1
p7.Transparency = 1
l7.Transparency = 1
sp6.Transparency = 0
sl6.Transparency = 0
l6.Transparency = 0
p6.Transparency = 0
wait(0.1)
p6.Transparency = 1
l6.Transparency = 1
sl6.Transparency = 1
sp6.Transparency = 1
sp5.Transparency = 0
sl5.Transparency = 0
l5.Transparency = 0
p5.Transparency = 0
wait(0.1)
p5.Transparency = 1
l5.Transparency = 1
sp5.Transparency = 1
sl5.Transparency = 1
sp4.Transparency = 0
sl4.Transparency = 0
l4.Transparency = 0
p4.Transparency = 0
wait(0.1)
p4.Transparency = 1
l4.Transparency = 1
sp4.Transparency = 1
sl4.Transparency = 1
sp3.Transparency = 0
sl3.Transparency = 0
l3.Transparency = 0
p3.Transparency = 0
wait(0.1)
p3.Transparency = 1
l3.Transparency = 1
sp3.Transparency = 1
sl3.Transparency = 1
sp2.Transparency = 0
sl2.Transparency = 0
l2.Transparency = 0
p2.Transparency = 0
wait(0.1)
p2.Transparency = 1
l2.Transparency = 1
sp2.Transparency = 1
sl2.Transparency = 1
sp1.Transparency = 0
sl1.Transparency = 0
l1.Transparency = 0
p1.Transparency = 0
wait(1)
q1.Transparency = 1
p1.Transparency = 1
l1.Transparency = 1
sp1.Transparency = 1
sl1.Transparency = 1
wait(0.1)
s1.Transparency = 0
wait(1)
g14.Transparency = 0
s1.Transparency = 1
pala7.Transparency = 1
wait(0.1)
g14.Transparency = 1
g13.Transparency = 0
wait(0.1)
g13.Transparency = 1
g12.Transparency = 0
wait(0.1)
g12.Transparency = 1
g11.Transparency = 0
wait(0.1)
g11.Transparency = 1
pala6.Transparency = 1
g10.Transparency = 0
wait(0.1)
g10.Transparency = 1
g9.Transparency = 0
wait(0.1)
g9.Transparency = 1
g8.Transparency = 0
wait(0.1)
g8.Transparency = 1
pala5.Transparency = 1
g7.Transparency = 0
wait(0.1)
g7.Transparency = 1
g6.Transparency = 0
wait(0.1)
g6.Transparency = 1
g5.Transparency = 0
pala4.Transparency = 1
wait(0.1)
g5.Transparency = 1
g4.Transparency = 0
wait(0.1)
g4.Transparency = 1
g3.Transparency = 0
pala3.Transparency = 1
wait(0.1)
g3.Transparency = 1
g2.Transparency = 0
wait(0.1)
pala2.Transparency = 1
g2.Transparency = 1
g1.Transparency = 0
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
|
--Audio
|
local soundBank = game.ReplicatedStorage.Sounds.NPC.Gobbler:GetChildren()
critter.Health.Changed:connect(function()
local hitSound = soundBank[math.random(1,#soundBank)]:Clone()
hitSound.Parent = critter.PrimaryPart
hitSound.PlayOnRemove = true
wait()
hitSound:Destroy()
end)
while true do
bp.Parent = critter.PrimaryPart
local goal
repeat
local ray = Ray.new(Vector3.new(origin.p.x+math.random(-tether,tether), critter.PrimaryPart.Position.Y+100, origin.p.z+math.random(-tether,tether)),Vector3.new(0,-130,0))
local part,pos,norm,mat = workspace:FindPartOnRay(ray,critter)
if part == workspace.Terrain and mat ~= Enum.Material.Water then
goal = pos+Vector3.new(0,2.25,0)
end
wait()
until goal
--Set new goal for critter to MoveTo :)
walk:Play()
local pos = critter.PrimaryPart.Position
local cf = CFrame.new(Vector3.new(pos.X, 0, pos.Z), Vector3.new(goal.X, 0, goal.Z))
bg.CFrame = cf
bp.Position = (cf*CFrame.new(0,0,-100)).p
local start = tick()
repeat wait(.5)
local ray = Ray.new(critter.PrimaryPart.Position, Vector3.new(0,-140,0))
until (critter.PrimaryPart.Position-goal).magnitude < 10 or tick()-start >10
walk:Stop()
bp.Parent = nil
wait(math.random(3,8))
end
|
-- Class
|
local ViewportWindow = {}
ViewportWindow.__index = ViewportWindow
|
-- Functions
|
function TeamManager:CreateTeams()
local newTeam = Instance.new("Team", game.Teams)
newTeam.TeamColor = BrickColor.new("Bright red")
TeamPlayers[newTeam] = {}
TeamScores[newTeam] = 0
newTeam = Instance.new("Team", game.Teams)
newTeam.TeamColor = BrickColor.new("Bright blue")
TeamPlayers[newTeam] = {}
TeamScores[newTeam] = 0
end
function TeamManager:CreateFFATeam()
local newTeamColor = BrickColor.Random()
while GetTeamFromColor(newTeamColor) do
newTeamColor = BrickColor.Random()
end
local newTeam = Instance.new("Team", game.Teams)
newTeam.TeamColor = newTeamColor
TeamPlayers[newTeam] = {}
TeamScores[newTeam] = 0
return newTeam
end
function TeamManager:AssignPlayerToTeam(player)
local smallestTeam
local lowestCount = math.huge
for team, playerList in pairs(TeamPlayers) do
if #playerList < lowestCount then
smallestTeam = team
lowestCount = #playerList
end
end
if not Configurations.TEAMS and (not smallestTeam or #TeamPlayers[smallestTeam] > 0) then
smallestTeam = TeamManager:CreateFFATeam()
end
table.insert(TeamPlayers[smallestTeam], player)
player.Neutral = false
player.TeamColor = smallestTeam.TeamColor
end
function TeamManager:RemovePlayer(player)
local team = GetTeamFromColor(player.TeamColor)
local teamTable = TeamPlayers[team]
for i = 1, #teamTable do
if teamTable[i] == player then
table.remove(teamTable, i)
if not Configurations.TEAMS then
team:Destroy()
end
return
end
end
end
function TeamManager:ClearTeamScores()
for _, team in pairs(Teams:GetTeams()) do
TeamScores[team] = 0
if Configurations.TEAMS then
DisplayManager:UpdateScore(team, 0)
end
end
end
function TeamManager:AddTeamScore(teamColor, score)
local team = GetTeamFromColor(teamColor)
TeamScores[team] = TeamScores[team] + score
if Configurations.TEAMS then
DisplayManager:UpdateScore(team, TeamScores[team])
end
end
function TeamManager:HasTeamWon()
for _, team in pairs(Teams:GetTeams()) do
if TeamScores[team] >= Configurations.POINTS_TO_WIN then
return team
end
end
return false
end
function TeamManager:GetWinningTeam()
local highestScore = 0
local winningTeam = nil
for _, team in pairs(Teams:GetTeams()) do
if TeamScores[team] > highestScore then
highestScore = TeamScores[team]
winningTeam = team
end
end
return winningTeam
end
function TeamManager:AreTeamsTied()
local teams = Teams:GetTeams()
local highestScore = 0
local tied = false
for _, team in pairs(teams) do
if TeamScores[team] == highestScore then
tied = true
elseif TeamScores[team] > highestScore then
tied = false
highestScore = TeamScores[team]
end
end
return tied
end
function TeamManager:ShuffleTeams()
for _, team in pairs(Teams:GetTeams()) do
TeamPlayers[team] = {}
end
local players = Players:GetPlayers()
while #players > 0 do
local rIndex = math.random(1, #players)
local player = table.remove(players, rIndex)
TeamManager:AssignPlayerToTeam(player)
end
end
|
--[[
Provides an API to use when referencing a Player's character
to make sure it is "Fully loaded", which is defined as:
1) Character is a descendant of workspace
2) Character has a PrimaryPart set
3) Character contains a child which is a Humanoid
4) The Humanoid's RootPart property is not nil
This differs from Player.CharacterAdded and Player.CharacterAppearanceLoaded which fire
before a character is parented to workspace and does not guarantee these other conditions.
This loaded event won't be necessary once the Player.CharacterAdded is moved to the end of the event
call stack, per https://devforum.roblox.com/t/avatar-loading-event-ordering-improvements/269607
This wrapper provides a died event when the first of the following happens:
1) Humanoid's .Died event fires
2) Character is removed
We need this because there are some cases where a character can be removed without the humanoid dying,
such as if :LoadCharacter() is called before a character dies. Cleanup code often needs to run when a
character's "lifespan" is over, whether it be because the humanoid died or because the character is removed.
To avoid having to connect to both events in multiple places, this wrapper moves both events into one.
--]]
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Workspace = game:GetService("Workspace")
local Signal = require(ReplicatedStorage.Source.Signal)
local Connections = require(ReplicatedStorage.Source.Connections)
local waitForChildOfClassAsync = require(ReplicatedStorage.Source.Utility.waitForChildOfClassAsync)
local function isPrimaryPartSet(character: Model)
return if character.PrimaryPart then true else false
end
local function isHumanoidRootPartSet(humanoid: Humanoid)
return if humanoid.RootPart then true else false
end
local function getHumanoid(character: Model)
return character:FindFirstChildOfClass("Humanoid")
end
local function isHumanoidAlive(character: Model)
local humanoidMaybe = getHumanoid(character)
if not humanoidMaybe then
return false
end
local humanoid = humanoidMaybe :: Humanoid
return isHumanoidRootPartSet(humanoid) and humanoid.Health > 0
end
local CharacterLoadedWrapper = {}
CharacterLoadedWrapper.__index = CharacterLoadedWrapper
export type ClassType = typeof(setmetatable(
{} :: {
loaded: Signal.ClassType,
died: Signal.ClassType,
_player: Player,
_destroyed: boolean,
_connections: Connections.ClassType,
},
CharacterLoadedWrapper
))
function CharacterLoadedWrapper.new(player: Player): ClassType
local self = {
loaded = Signal.new(),
died = Signal.new(),
_player = player,
_destroyed = false,
_connections = Connections.new(),
}
setmetatable(self, CharacterLoadedWrapper)
self:_listenForCharacterAdded()
return self
end
function CharacterLoadedWrapper.isLoaded(self: ClassType, optionalCharacter: Model?)
-- Character can be passed in to check if a specific character model is
-- the currently loaded character model. Useful if you are maintaining a reference
-- to a specific character model, you want to verify that :isLoaded() is true, but
-- you also want to make sure your current character reference isn't out of date.
local characterMaybe = optionalCharacter or self._player.Character
if not characterMaybe then
return false
end
local character = characterMaybe :: Model
return isPrimaryPartSet(character) and isHumanoidAlive(character) and character:IsDescendantOf(Workspace)
end
function CharacterLoadedWrapper._listenForCharacterAdded(self: ClassType)
task.spawn(function()
local character = self._player.Character
-- Avoids firing .loaded event when the character is already loaded
if character then
if self:isLoaded() then
self:_listenForDeath(character)
else
self:_waitForLoadedAsync(character)
end
end
local characterAddedConnection = self._player.CharacterAdded:Connect(function(newCharacter: Model)
self:_waitForLoadedAsync(newCharacter)
end)
self._connections:add(characterAddedConnection)
end)
end
|
-- Set anchor at offset from absolute position
|
function Element:setAnchor(offsetX, offsetY)
if(offsetX > self:getSize().x or offsetY > self:getSize().y or offsetX < 0 or offsetY < 0) then
error("Attempt to set anchor beyond element's bounds")
else
self.anchor = Vector2.new(offsetX, offsetY)
end
end
function Element:isDisplayed()
return self:getRbxInstance().Visible
end
function Element:isSelected()
return self:getRbxInstance().Selected
end
function Element:getRbxInstance()
return self:waitForRbxInstance(self.path.waitDelay, self.path.waitTimeout)
end
function Element:waitForRbxInstance(timeout, delay)
if self.rbxInstance == nil and self.path ~= nil then
self.path:setWait(timeout, delay)
self.rbxInstance = self.path:waitForFirstInstance()
end
if self.rbxInstance and not self.anchor then
if pcall(function() local size = self.rbxInstance.AbsoluteSize end) then
self.anchor = self.rbxInstance.AbsoluteSize/2
else
self.anchor = nil
end
end
return self.rbxInstance
end
function Element:_override(class)
for k, v in pairs(class) do
if not k:find("^_") then
self[k] = v
end
end
end
function Element:centralizeInstance()
self:_centralizeInScrollingFrame(self:getRbxInstance())
end
function Element:centralize()
local instance = self:getRbxInstance()
if instance then
self:centralizeInstance()
else
self:centralizeWithInfiniteScrolling()
end
end
function Element:_scrollingFrames(instance)
if instance == nil or instance == game then return 0 end
local num = self:_scrollingFrames(instance.Parent)
if instance.ClassName == "ScrollingFrame" then num = num + 1 end
return num
end
function Element:_centralizeInScrollingFrame(child, parent)
if child == game then return end
parent = parent or child.Parent
if parent == game then return end
if parent.ClassName == "ScrollingFrame" then
self:_centralizeInScrollingFrame(parent, parent.Parent)
-- this is computational error tolerate.
local threshold = 2
--first scroll down to make child appears neas screen,
--so that we can access child.AbsolutPosition property
local isChildInScreen = false
while not isChildInScreen do
local prevChildPosition = child.AbsolutePosition
local prevCanvasPosition = parent.CanvasPosition
-- when scroll too much at one time, the element may move out side of screen immediately
-- its AbsoluteSize will not update. limit to 300
local scrollDistance = Vector2.new(math.min(300, parent.AbsoluteSize.X), math.min(300, parent.AbsoluteSize.Y))
parent.CanvasPosition = parent.CanvasPosition + scrollDistance
wait()
local deltaCanvas = (parent.CanvasPosition - prevCanvasPosition)
local isBottom = deltaCanvas.Magnitude <= threshold
local deltaChild = child.AbsolutePosition - prevChildPosition
isChildInScreen = isBottom or deltaChild.Magnitude > threshold
end
--second scroll to centerize the child, at most twice.
for _ = 1, 2 do
local frameCenter = parent.AbsolutePosition + parent.AbsoluteSize/2
local childCenter = child.AbsolutePosition + child.AbsoluteSize/2
local delta = childCenter - frameCenter
if delta.Magnitude <= threshold then break end
parent.CanvasPosition = parent.CanvasPosition + delta
wait()
end
else
self:_centralizeInScrollingFrame(child, parent.Parent)
end
end
function Element:_scrollToFindInstance(scrollingFrame, absPath)
|
-- Local Functions
|
local function StartIntermission()
-- Find flag to circle. Default to circle center of map
local possiblePoints = {}
table.insert(possiblePoints, Vector3.new(0,50,0))
for _, child in ipairs(game.Workspace:GetChildren()) do
if child.Name == "FlagStand" then
table.insert(possiblePoints, child.FlagStand.Position)
end
end
local focalPoint = possiblePoints[math.random(#possiblePoints)]
Camera.CameraType = Enum.CameraType.Scriptable
Camera.Focus = CFrame.new(focalPoint)
local angle = 0
game.Lighting.Blur.Enabled = true
RunService:BindToRenderStep('IntermissionRotate', Enum.RenderPriority.Camera.Value, function()
local cameraPosition = focalPoint + Vector3.new(50 * math.cos(angle), 20, 50 * math.sin(angle))
Camera.CoordinateFrame = CFrame.new(cameraPosition, focalPoint)
angle = angle + math.rad(.25)
end)
end
local function StopIntermission()
game.Lighting.Blur.Enabled = false
RunService:UnbindFromRenderStep('IntermissionRotate')
Camera.CameraType = Enum.CameraType.Custom
end
local function OnDisplayIntermission(display)
if display and not InIntermission then
InIntermission = true
StartIntermission()
end
if not display and InIntermission then
InIntermission = false
StopIntermission()
end
end
|
--Var
|
local farawayCFrame: CFrame = CFrame.new(0, 10e8, 0)
|
-- If you want to know how to retexture a hat, read this: http://www.roblox.com/Forum/ShowPost.aspx?PostID=10502388
|
debounce = true
function onTouched(hit)
if (hit.Parent:findFirstChild("Humanoid") ~= nil and debounce == true) then
debounce = false
h = Instance.new("Hat")
p = Instance.new("Part")
h.Name = "Hat" -- It doesn't make a difference, but if you want to make your place in Explorer neater, change this to the name of your hat.
p.Parent = h
p.Position = hit.Parent:findFirstChild("Head").Position
p.Name = "Handle"
p.formFactor = 0
p.Size = Vector3.new(-0,-0,-1)
p.BottomSurface = 0
p.TopSurface = 0
p.Locked = true
script.Parent.Mesh:clone().Parent = p
h.Parent = hit.Parent
h.AttachmentPos = Vector3.new(0, -0.45, -0.01) -- Change these to change the positiones of your hat, as I said earlier.
wait(5) debounce = true
end
end
script.Parent.Touched:connect(onTouched)
|
--[[ The rest isn't as customizable" ]]
|
--
debrisS, playerS, datastoreS, gamepassS, marketS =
game:GetService("Debris"),
game:GetService("Players"),
game:GetService("DataStoreService"),
game:GetService("GamePassService"),
game:GetService("MarketplaceService")
function passedPlayer(p, isLeaving)
print(p.Name.." has passed")
local function sendMessage(txt)
if gameStats["DoMessages?"] then
local message = Instance.new("Message", p.PlayerGui)
message.Text = txt
debrisS:AddItem(message, 2)
end
end
local save, load =
function()
local cDatastore, statStorage =
datastoreS:GetDataStore(p.Name.."Stats"),
p:WaitForChild("PlayerData"):GetChildren()
for i = 1, #statStorage do
cDatastore:SetAsync(statStorage[i].Name, statStorage[i].Value)
end
sendMessage("Your stats have been saved.")
end,
function()
local cDatastore, stats =
datastoreS:GetDataStore(p.Name.."Stats"),
p:FindFirstChild("PlayerData"):GetChildren()
for i = 1, #stats do
stats[i].Value = cDatastore:GetAsync(stats[i].Name)
end
sendMessage("Your stats have been loaded.")
end
local chatted = function(c)
c = c:lower()
for i, v in pairs(gameStats["DoChat?"]["Keywords"]) do
if (c == v) then
save()
end
end
end
if isLeaving then
save()
else
load()
if gameStats["DoChat?"]["DoIt?"] then
p["Chatted"]:connect(chatted)
end
end
end
function passTest(p, isLeaving)
print("Test starting")
if gameStats["IsAnObby?"] then
local cAdded = function(c)
p:LoadCharacter(true)
end
p["CharacterAdded"]:connect(cAdded)
end
if gameStats.saveType["Normal?"] then
passedPlayer(p, isLeaving)
else
if gameStats.saveType["SavingList?"]["DoIt?"] then
for i, v in pairs(gameStats.saveType["SavingList?"].theList) do
if (p.Name == v) then
passedPlayer(p, isLeaving)
end
end
elseif gameStats.saveType["BestFriends?"] then
if p:IsBestFriendsWith(game.CreatorId) then
passedPlayer(p, isLeaving)
end
elseif gameStats.saveType["Friends?"] then
if p:IsFriendsWith(game.CreatorId) then
passedPlayer(p, isLeaving)
end
elseif gameStats.saveType["OwnerOnly?"] then
if (p.userId == game.CreatorId) then
passedPlayer(p, isLeaving)
end
elseif gameStats.saveType["Gamepass?"]["DoIt?"] then
if p:PlayerHasPass(p, gameStats.saveType["Gamepass?"]["GamepassId"]) then
passedPlayer(p, isLeaving)
end
elseif gameStats.saveType["Asset/Item?"]["DoIt?"] then
if p:PlayerOwnsAsset(p, gameStats.saveType["Asset/Item?"]["AssetId"]) then
passedPlayer(p, isLeaving)
end
end
end
end
pAdded, pLeaving =
function(p)
local lStats = false
while true do
if p:findFirstChild("PlayerData") then
lStats = p:findFirstChild("PlayerData")
passTest(p, false)
break
end
wait()
end
end,
function(p)
passTest(p, true)
end
playerS["PlayerAdded"]:connect(pAdded)
playerS["PlayerRemoving"]:connect(pLeaving)
|
--[[
Create a new binding object with the given starting value. This
function will be exposed to users of Roact.
]]
|
function Binding.create(initialValue)
local binding = {
[Type] = Type.Binding,
[InternalData] = {
value = initialValue,
changeSignal = createSignal(),
subscriberCount = 0,
valueTransform = identity,
upstreamBinding = nil,
upstreamDisconnect = nil,
},
}
setmetatable(binding, bindingPrototype)
local setter = function(newValue)
Binding.update(binding, newValue)
end
return binding, setter
end
return Binding
|
-- Used by event system to capture/rethrow the first error.
|
local hasRethrowError = false
local rethrowError = nil
local reporter = {
onError = function(err)
hasError = true
caughtError = err
end,
}
local exports = {}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.