prompt
stringlengths 2
14.7k
| completion
stringlengths 1
99.7k
|
---|---|
--Localize |
local instance,newRay = Instance.new,Ray.new
local v2,v3,cf,udim2 = Vector2.new,Vector3.new,CFrame.new,UDim2.new
local insert,random,abs = table.insert,math.random,math.abs
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
|
-- Torso |
character.Constraint.ConstraintUpperTorso.Attachment0 = UTJoint
character.Constraint.ConstraintUpperTorso.Attachment1 = LTJoint |
--local warmSteam = steam:WaitForChild("WarmSteam")
--local hotSteam = steam:WaitForChild("HotSteam") |
local showerHead = p.ShowerHead.Spout.ParticleEmitter
|
--𝐁𝐮 𝐊𝐢𝐭 𝐇𝐞𝐲𝐞𝐜𝐚𝐧𝐥ı𝐘𝐓 𝐓𝐚𝐫𝐚𝐟ı𝐧𝐝𝐚𝐧 𝐘𝐚𝐩ı𝐥𝐦ış𝐭ı𝐫 İ𝐳𝐢𝐧𝐬𝐢𝐳 𝐕𝐢𝐝𝐞𝐨𝐬𝐮 Ç𝐞𝐤𝐢𝐥𝐦𝐞𝐬𝐢 𝐘𝐚𝐬𝐚𝐤𝐭ı𝐫 |
while true do
for i, v in pairs(game.Players:GetPlayers()) do
local Stats = v.leaderstats:WaitForChild(StatsName).Value
if Stats then
pcall(function()--𝐁𝐮 𝐊𝐢𝐭 𝐇𝐞𝐲𝐞𝐜𝐚𝐧𝐥ı𝐘𝐓 𝐓𝐚𝐫𝐚𝐟ı𝐧𝐝𝐚𝐧 𝐘𝐚𝐩ı𝐥𝐦ış𝐭ı𝐫 İ𝐳𝐢𝐧𝐬𝐢𝐳 𝐕𝐢𝐝𝐞𝐨𝐬𝐮 Ç𝐞𝐤𝐢𝐥𝐦𝐞𝐬𝐢 𝐘𝐚𝐬𝐚𝐤𝐭ı𝐫
DataStore:UpdateAsync(v.UserId, function(Value)
return tonumber(Stats)
end)
end)
end
end
for i, v in pairs(ItemsFrame:GetChildren()) do--𝐁𝐮 𝐊𝐢𝐭 𝐇𝐞𝐲𝐞𝐜𝐚𝐧𝐥ı𝐘𝐓 𝐓𝐚𝐫𝐚𝐟ı𝐧𝐝𝐚𝐧 𝐘𝐚𝐩ı𝐥𝐦ış𝐭ı𝐫 İ𝐳𝐢𝐧𝐬𝐢𝐳 𝐕𝐢𝐝𝐞𝐨𝐬𝐮 Ç𝐞𝐤𝐢𝐥𝐦𝐞𝐬𝐢 𝐘𝐚𝐬𝐚𝐤𝐭ı𝐫
if v:IsA("ImageLabel") then
v:Destroy()
end--𝐁𝐮 𝐊𝐢𝐭 𝐇𝐞𝐲𝐞𝐜𝐚𝐧𝐥ı𝐘𝐓 𝐓𝐚𝐫𝐚𝐟ı𝐧𝐝𝐚𝐧 𝐘𝐚𝐩ı𝐥𝐦ış𝐭ı𝐫 İ𝐳𝐢𝐧𝐬𝐢𝐳 𝐕𝐢𝐝𝐞𝐨𝐬𝐮 Ç𝐞𝐤𝐢𝐥𝐦𝐞𝐬𝐢 𝐘𝐚𝐬𝐚𝐤𝐭ı𝐫
end
GetItems()--𝐁𝐮 𝐊𝐢𝐭 𝐇𝐞𝐲𝐞𝐜𝐚𝐧𝐥ı𝐘𝐓 𝐓𝐚𝐫𝐚𝐟ı𝐧𝐝𝐚𝐧 𝐘𝐚𝐩ı𝐥𝐦ış𝐭ı𝐫 İ𝐳𝐢𝐧𝐬𝐢𝐳 𝐕𝐢𝐝𝐞𝐨𝐬𝐮 Ç𝐞𝐤𝐢𝐥𝐦𝐞𝐬𝐢 𝐘𝐚𝐬𝐚𝐤𝐭ı𝐫
wait()
SurfaceGui.Heading.Heading.Text = StatsName .. " Leaderboard"--𝐁𝐮 𝐊𝐢𝐭 𝐇𝐞𝐲𝐞𝐜𝐚𝐧𝐥ı𝐘𝐓 𝐓𝐚𝐫𝐚𝐟ı𝐧𝐝𝐚𝐧 𝐘𝐚𝐩ı𝐥𝐦ış𝐭ı𝐫 İ𝐳𝐢𝐧𝐬𝐢𝐳 𝐕𝐢𝐝𝐞𝐨𝐬𝐮 Ç𝐞𝐤𝐢𝐥𝐦𝐞𝐬𝐢 𝐘𝐚𝐬𝐚𝐤𝐭ı𝐫
List.ListContent.GuideTopBar.Value.Text = StatsName
List.CanvasSize = UDim2.new(0, 0, 0, ItemsFrame.UIListLayout.AbsoluteContentSize.Y + 35)
wait(UpdateEvery)
end--𝐁𝐮 𝐊𝐢𝐭 𝐇𝐞𝐲𝐞𝐜𝐚𝐧𝐥ı𝐘𝐓 𝐓𝐚𝐫𝐚𝐟ı𝐧𝐝𝐚𝐧 𝐘𝐚𝐩ı𝐥𝐦ış𝐭ı𝐫 İ𝐳𝐢𝐧𝐬𝐢𝐳 𝐕𝐢𝐝𝐞𝐨𝐬𝐮 Ç𝐞𝐤𝐢𝐥𝐦𝐞𝐬𝐢 𝐘𝐚𝐬𝐚𝐤𝐭ı𝐫
|
--//doors |
local dl = Instance.new("Motor", script.Parent.Parent.Misc.FL.Door.SS)
dl.MaxVelocity = 0.03
dl.Part0 = script.Parent.FL
dl.Part1 = dl.Parent
local dr = Instance.new("Motor", script.Parent.Parent.Misc.FR.Door.SS)
dr.MaxVelocity = 0.03
dr.Part0 = script.Parent.FR
dr.Part1 = dr.Parent
|
--- Code that will be run when the block is added to a InfoOverlay. Used to customize and edit the appearance or add functionality. |
return function(blockGui, blockName, ...)
local title = ...
blockGui.title.Text = title .. "!"
end
|
-- General settings |
local XRAY_TIME = 10
local COOLDOWN = 25
local plr = game.Players.LocalPlayer
local inputService = game:GetService("UserInputService")
game.ReplicatedStorage.Interactions.Client.Perks.UseXRay.OnClientEvent:connect(function()
-- Make sure character is alive
if plr.Character ~= nil then
local originalChr = plr.Character
-- Show tip
plr.PlayerGui.MainGui.Tip.Text = "Press Q to use X-Ray"
-- Set map object
local map = workspace:FindFirstChild("Map")
-- Connect input event
local debounce = false
local event
local done = false
event = inputService.InputBegan:connect(function(inputObj)
-- Check if states are correct
if not debounce and not done and inputObj.KeyCode == Enum.KeyCode.Q and workspace:FindFirstChild("Map") == map then
debounce = true
-- Show location of each player
local playingPlayers = game.ReplicatedStorage.Interactions.Server.GetPlayingPlayers:InvokeServer()
for n, i in pairs(playingPlayers) do
if i == plr then
table.remove(playingPlayers, n)
break
end
end
for _, i in pairs(playingPlayers) do
-- Make sure character is alive
local chr = i.Character
if chr ~= nil and chr:FindFirstChild("Humanoid") and chr.Humanoid.Health > 0 and chr:FindFirstChild("Torso") then
-- Place X Gui in torso
local gui = script.XMarker:clone()
gui.Parent = chr.Torso
-- Remove after 10 seconds
spawn(function()
wait(XRAY_TIME)
if gui ~= nil then
gui:destroy()
gui = nil
end
end)
-- Connect death
chr.Humanoid.Died:connect(function()
if gui ~= nil then
gui:destroy()
gui = nil
end
end)
end
end
-- Update text to match state
for i=1, XRAY_TIME do
if done or workspace:FindFirstChild("Map") == nil then
break
end
plr.PlayerGui.MainGui.Tip.Text = "Can see others for " .. (XRAY_TIME - i + 1) .. " seconds"
wait(1)
end
if not done and workspace:FindFirstChild("Map") then
for i=1, COOLDOWN do
if done or workspace:FindFirstChild("Map") == nil then
break
end
plr.PlayerGui.MainGui.Tip.Text = "Can use again in " .. (COOLDOWN - i + 1) .. " seconds"
wait(1)
end
if not done and workspace:FindFirstChild("Map") then
plr.PlayerGui.MainGui.Tip.Text = "Press Q to turn use X-Ray"
end
end
if done or workspace:FindFirstChild("Map") == nil then
if event ~= nil then
event:disconnect()
event = nil
end
done = true
plr.PlayerGui.MainGui.Tip.Text = ""
end
debounce = false
elseif workspace:FindFirstChild("Map") ~= map then
if event ~= nil then
event:disconnect()
event = nil
end
done = true
plr.PlayerGui.MainGui.Tip.Text = ""
end
end)
-- Connect disconnect
originalChr.Humanoid.Died:connect(function()
if not done then
event:disconnect()
event = nil
done = true
plr.PlayerGui.MainGui.Tip.Text = ""
end
end)
end
end)
|
--[[
Returns the value of an attribute on an instance, erroring if the
attribute doesn't exist. Normally, calling :GetAttribute() doesn't error,
but in most cases, getting an attribute should only happen where it's guaranteed
to exist, and we therefore want it to error.
--]] |
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Attribute = require(ReplicatedStorage.Source.SharedConstants.Attribute)
local function getAttribute<T>(instance: Instance, attributeName: Attribute.EnumType): T
local value = instance:GetAttribute(attributeName)
assert(value ~= nil, ("%s is not a valid attribute of %s"):format(attributeName, instance:GetFullName()))
return value
end
return getAttribute
|
--[[
[How fast the body rotates.]
[If you set it on 0, your torso and head won't move, if you set it on 0.5, it'll look smoother, if you set it on 1, it will do instant rotate.]
[Setting this any higher than 1 causes weird glitchy shaking occasionally.]
--]] |
local UpdateSpeed = 1
local NeckOrgnC0 = Neck.C0 --[Get the base C0 to manipulate off of.]
local WaistOrgnC0 = (not IsR6 and Waist.C0) --[Get the base C0 to manipulate off of.]
|
-- play the animation |
toolAnimTrack:Play(transitionTime)
toolAnimName = animName
toolAnimInstance = anim
currentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:Connect(toolKeyFrameReachedFunc)
end
end
function stopToolAnimations()
local oldAnim = toolAnimName
if (currentToolAnimKeyframeHandler ~= nil) then
currentToolAnimKeyframeHandler:Disconnect()
end
toolAnimName = ""
toolAnimInstance = nil
if (toolAnimTrack ~= nil) then
toolAnimTrack:Stop()
toolAnimTrack:Destroy()
toolAnimTrack = nil
end
return oldAnim
end |
-- Constants |
local ITERATIONS = 8
local FixedRate = 1 / 60
local MaxSkips = 120
local iterdt = FixedRate / ITERATIONS
|
--!nocheck |
local LocalizationService = game:GetService("LocalizationService")
local ChatService = game:GetService("Chat")
local success, userShouldLocalizeServerMessages = pcall(function() return UserSettings():IsUserFeatureEnabled("UserShouldLocalizeServerMessages") end)
local userShouldLocalizeServerMessages = success and userShouldLocalizeServerMessages
local existingKey = {
["System"] = "InGame.Chat.Label.SystemMessagePrefix",
["Team"] = "InGame.Chat.Label.TeamMessagePrefix",
["From "] = "InGame.Chat.Label.From",
["To "] = "InGame.Chat.Label.To",
}
local ChatLocalization = {
_hasFetchedLocalization = false,
}
function ChatLocalization:_getTranslator()
if not self._translator and not self._hasFetchedLocalization then
-- Don't keep retrying if this fails.
self._hasFetchedLocalization = true
local localizationTable = ChatService:WaitForChild("ChatLocalization", 4)
if localizationTable then
self._translator = localizationTable:GetTranslator(LocalizationService.RobloxLocaleId)
LocalizationService:GetPropertyChangedSignal("RobloxLocaleId"):Connect(function()
-- If RobloxLocaleId changes invalidate the cached Translator.
self._hasFetchedLocalization = false
self._translator = nil
end)
else
warn("Missing ChatLocalization. Chat interface will not be localized.")
end
end
return self._translator
end
function ChatLocalization:Get(key, default, extraParameters)
local rtv = default
pcall(function()
local translator = self:_getTranslator()
if translator then
rtv = translator:FormatByKey(key, extraParameters)
else
warn("Missing Translator. Used default for", key)
end
end)
return rtv
end
function ChatLocalization:LocalizeFormattedMessage(message)
if not userShouldLocalizeServerMessages then
return message
end
local keyStart, keyEnd = string.find(message, "{RBX_LOCALIZATION_KEY}")
if not keyStart then
return message
end
local defaultStart, defaultEnd = string.find(message, "{RBX_LOCALIZATION_DEFAULT}")
if not defaultStart then
return message
end
local paramStart, paramEnd = string.find(message, "{RBX_LOCALIZATION_PARAMS}")
local key = string.sub(message, keyEnd + 1, defaultStart - 1)
local default
if not paramStart then
default = string.sub(message, defaultEnd + 1)
return self:Get(key, default)
end
default = string.sub(message, defaultEnd + 1, paramStart - 1)
local params = string.sub(message, paramEnd + 1)
local extraParameters = {}
for k,v in string.gmatch(params,"([^%s]+)=([^%s]+)") do
extraParameters[k] = v
end
return self:Get(key, default, extraParameters)
end
function ChatLocalization:FormatMessageToSend(key, defaultMessage, parameterName, value)
if userShouldLocalizeServerMessages then
if parameterName and value then
return "{RBX_LOCALIZATION_KEY}"..key.."{RBX_LOCALIZATION_DEFAULT}"..defaultMessage
.."{RBX_LOCALIZATION_PARAMS}"..parameterName.."="..value
else
return "{RBX_LOCALIZATION_KEY}"..key.."{RBX_LOCALIZATION_DEFAULT}"..defaultMessage
end
else
if parameterName and value then
return string.gsub(self:Get(key,defaultMessage), "{"..parameterName.."}", value)
else
return self:Get(key,defaultMessage)
end
end
end
|
-- in the aboutWindow |
aboutCloseButton.MouseButton1Down:Connect(function()
topbar_acloseButton_p:Play()
hideAboutWindow()
lightenScreen()
end)
aboutCloseButton.MouseButton1Up:Connect(function()
topbar_acloseButton_f:Cancel()
topbar_aclosebutton_r:Play()
topbar_aclosebutton_r.Completed:Wait()
topbar_acloseButton_nf:Play()
end)
|
-- Decompiled with the Synapse X Luau decompiler. |
local l__RunService__1 = game:GetService("RunService");
local l__ReplicatedStorage__2 = game:GetService("ReplicatedStorage");
local l__Chat__3 = game:GetService("Chat");
local l__StarterGui__4 = game:GetService("StarterGui");
local v5 = l__ReplicatedStorage__2:WaitForChild("DefaultChatSystemChatEvents");
local v6 = l__ReplicatedStorage__2:WaitForChild("DefaultChatSystemChatEvents");
local l__ClientChatModules__7 = l__Chat__3:WaitForChild("ClientChatModules");
local v8 = require(l__ClientChatModules__7:WaitForChild("ChatConstants"));
local v9 = require(l__ClientChatModules__7:WaitForChild("ChatSettings"));
local v10 = require(l__ClientChatModules__7:WaitForChild("MessageCreatorModules"):WaitForChild("Util"));
local u1 = nil;
pcall(function()
u1 = require(game:GetService("Chat").ClientChatModules.ChatLocalization);
end);
if u1 == nil then
u1 = {
Get = function(p1, p2, p3)
return p3;
end
};
end;
local v11 = Instance.new("BindableEvent");
local u2 = {
OnNewMessage = "RemoteEvent",
OnMessageDoneFiltering = "RemoteEvent",
OnNewSystemMessage = "RemoteEvent",
OnChannelJoined = "RemoteEvent",
OnChannelLeft = "RemoteEvent",
OnMuted = "RemoteEvent",
OnUnmuted = "RemoteEvent",
OnMainChannelSet = "RemoteEvent",
SayMessageRequest = "RemoteEvent",
GetInitDataRequest = "RemoteFunction"
};
local u3 = {};
local u4 = 10;
function TryRemoveChildWithVerifyingIsCorrectType(p4)
if u2[p4.Name] then
if p4:IsA(u2[p4.Name]) then
u2[p4.Name] = nil;
u3[p4.Name] = p4;
u4 = u4 - 1;
end;
end;
end;
for v12, v13 in pairs(v6:GetChildren()) do
TryRemoveChildWithVerifyingIsCorrectType(v13);
end;
if u4 > 0 then
local v14 = v6.ChildAdded:connect(function(p5)
TryRemoveChildWithVerifyingIsCorrectType(p5);
if u4 < 1 then
v11:Fire();
end;
end);
v11.Event:wait();
v14:disconnect();
v11:Destroy();
end;
local l__UserInputService__15 = game:GetService("UserInputService");
local l__RunService__16 = game:GetService("RunService");
local l__Players__17 = game:GetService("Players");
local v18 = l__Players__17.LocalPlayer;
while not v18 do
l__Players__17.ChildAdded:wait();
v18 = l__Players__17.LocalPlayer;
end;
local v19 = 6;
if v9.ScreenGuiDisplayOrder ~= nil then
v19 = v9.ScreenGuiDisplayOrder;
end;
local v20 = Instance.new("ScreenGui");
v20.Name = "Chat";
v20.ResetOnSpawn = false;
v20.DisplayOrder = v19;
v20.Parent = v18:WaitForChild("PlayerGui");
local v21 = require(script:WaitForChild("MessageLabelCreator"));
local v22 = require(script:WaitForChild("MessageLogDisplay"));
local v23 = require(script:WaitForChild("ChatChannel"));
local v24 = require(script:WaitForChild("ChatWindow")).new();
local v25 = require(script:WaitForChild("ChannelsBar")).new();
local v26 = v22.new();
local v27 = require(script:WaitForChild("CommandProcessor")).new();
local v28 = require(script:WaitForChild("ChatBar")).new(v27, v24);
v24:CreateGuiObjects(v20);
v24:RegisterChatBar(v28);
v24:RegisterChannelsBar(v25);
v24:RegisterMessageLogDisplay(v26);
v10:RegisterChatWindow(v24);
local v29 = require(script:WaitForChild("MessageSender"));
v29:RegisterSayMessageFunction(u3.SayMessageRequest);
if l__UserInputService__15.TouchEnabled then
v28:SetTextLabelText(u1:Get("GameChat_ChatMain_ChatBarText", "Tap here to chat"));
else
v28:SetTextLabelText(u1:Get("GameChat_ChatMain_ChatBarTextTouch", "To chat click here or press \"/\" key"));
end;
local l__script__5 = script;
spawn(function()
local v30 = require(l__script__5:WaitForChild("CurveUtil"));
local v31 = 1 / (v9.ChatAnimationFPS and 20);
local v32 = tick();
while true do
local v33 = tick();
local v34 = v30:DeltaTimeToTimescale(v33 - v32);
if v34 ~= 0 then
v24:Update(v34);
end;
v32 = v33;
wait(v31);
end;
end);
function CheckIfPointIsInSquare(p6, p7, p8)
local v35 = false;
if p7.X <= p6.X then
v35 = false;
if p6.X <= p8.X then
v35 = false;
if p7.Y <= p6.Y then
v35 = p6.Y <= p8.Y;
end;
end;
end;
return v35;
end;
local u6 = 0;
local u7 = false;
local u8 = Instance.new("BindableEvent");
function DoBackgroundFadeIn(p9)
u6 = tick();
u7 = false;
u8:Fire();
v24:FadeInBackground(p9 or v9.ChatDefaultFadeDuration);
if v24:GetCurrentChannel() then
local l__Scroller__36 = v26.Scroller;
l__Scroller__36.ScrollingEnabled = true;
l__Scroller__36.ScrollBarThickness = v22.ScrollBarThickness;
end;
end;
function DoBackgroundFadeOut(p10)
u6 = tick();
u7 = true;
u8:Fire();
v24:FadeOutBackground(p10 or v9.ChatDefaultFadeDuration);
if v24:GetCurrentChannel() then
local l__Scroller__37 = v26.Scroller;
l__Scroller__37.ScrollingEnabled = false;
l__Scroller__37.ScrollBarThickness = 0;
end;
end;
local u9 = 0;
local u10 = false;
function DoTextFadeIn(p11)
u9 = tick();
u10 = false;
u8:Fire();
v24:FadeInText((p11 or v9.ChatDefaultFadeDuration) * 0);
end;
function DoTextFadeOut(p12)
u9 = tick();
u10 = true;
u8:Fire();
v24:FadeOutText(p12 or v9.ChatDefaultFadeDuration);
end;
function DoFadeInFromNewInformation()
DoTextFadeIn();
if v9.ChatShouldFadeInFromNewInformation then
DoBackgroundFadeIn();
end;
end;
function InstantFadeIn()
DoBackgroundFadeIn(0);
DoTextFadeIn(0);
end;
function InstantFadeOut()
DoBackgroundFadeOut(0);
DoTextFadeOut(0);
end;
local u11 = nil;
local u12 = Instance.new("BindableEvent");
function UpdateFadingForMouseState(p13)
u11 = p13;
u12:Fire();
if v28:IsFocused() then
return;
end;
if p13 then
else
DoBackgroundFadeIn();
return;
end;
DoBackgroundFadeIn();
DoTextFadeIn();
end;
local u13 = Instance.new("BindableEvent");
spawn(function()
while true do
l__RunService__16.RenderStepped:wait();
while not (not u11) or not (not v28:IsFocused()) do
if u11 then
u12.Event:wait();
end;
if v28:IsFocused() then
u13.Event:wait();
end;
end;
if not u7 then
if v9.ChatWindowBackgroundFadeOutTime < tick() - u6 then
DoBackgroundFadeOut();
end;
elseif not u10 then
if v9.ChatWindowTextFadeOutTime < tick() - u9 then
DoTextFadeOut();
end;
else
u8.Event:wait();
end;
end;
end);
function getClassicChatEnabled()
if v9.ClassicChatEnabled ~= nil then
return v9.ClassicChatEnabled;
end;
return l__Players__17.ClassicChat;
end;
function getBubbleChatEnabled()
if v9.BubbleChatEnabled ~= nil then
return v9.BubbleChatEnabled;
end;
return l__Players__17.BubbleChat;
end;
function bubbleChatOnly()
return not getClassicChatEnabled() and getBubbleChatEnabled();
end;
local u14 = {};
function UpdateMousePosition(p14)
if u14.Visible then
if u14.IsCoreGuiEnabled then
if not u14.TopbarEnabled then
if not v9.ChatOnWithTopBarOff then
return;
end;
end;
else
return;
end;
else
return;
end;
if bubbleChatOnly() then
return;
end;
local l__AbsolutePosition__38 = v24.GuiObject.AbsolutePosition;
local v39 = CheckIfPointIsInSquare(p14, l__AbsolutePosition__38, l__AbsolutePosition__38 + v24.GuiObject.AbsoluteSize);
if v39 ~= u11 then
UpdateFadingForMouseState(v39);
end;
end;
l__UserInputService__15.InputChanged:connect(function(p15)
if p15.UserInputType == Enum.UserInputType.MouseMovement then
UpdateMousePosition((Vector2.new(p15.Position.X, p15.Position.Y)));
end;
end);
l__UserInputService__15.TouchTap:connect(function(p16, p17)
UpdateMousePosition(p16[1]);
end);
l__UserInputService__15.TouchMoved:connect(function(p18, p19)
UpdateMousePosition((Vector2.new(p18.Position.X, p18.Position.Y)));
end);
l__UserInputService__15.Changed:connect(function(p20)
if p20 == "MouseBehavior" and l__UserInputService__15.MouseBehavior == Enum.MouseBehavior.LockCenter then
local l__AbsolutePosition__40 = v24.GuiObject.AbsolutePosition;
if CheckIfPointIsInSquare(v20.AbsoluteSize / 2, l__AbsolutePosition__40, l__AbsolutePosition__40 + v24.GuiObject.AbsoluteSize) then
l__UserInputService__15.MouseBehavior = Enum.MouseBehavior.Default;
end;
end;
end);
UpdateFadingForMouseState(true);
UpdateFadingForMouseState(false);
local v41 = {
Signal = function()
local v42 = {};
local u15 = nil;
local u16 = nil;
local u17 = Instance.new("BindableEvent");
function v42.fire(p21, ...)
u15 = { ... };
u16 = select("#", ...);
u17:Fire();
end;
function v42.connect(p22, p23)
if not p23 then
error("connect(nil)", 2);
end;
return u17.Event:connect(function()
p23(unpack(u15, 1, u16));
end);
end;
function v42.wait(p24)
u17.Event:wait();
assert(u15, "Missing arg data, likely due to :TweenSize/Position corrupting threadrefs.");
return unpack(u15, 1, u16);
end;
return v42;
end
};
function SetVisibility(p25)
v24:SetVisible(p25);
u14.VisibilityStateChanged:fire(p25);
u14.Visible = p25;
if u14.IsCoreGuiEnabled then
if p25 then
else
InstantFadeOut();
return;
end;
else
return;
end;
InstantFadeIn();
end;
u14.TopbarEnabled = true;
u14.MessageCount = 0;
u14.Visible = true;
u14.IsCoreGuiEnabled = true;
function u14.ToggleVisibility(p26)
SetVisibility(not v24:GetVisible());
end;
function u14.SetVisible(p27, p28)
if v24:GetVisible() ~= p28 then
SetVisibility(p28);
end;
end;
function u14.FocusChatBar(p29)
v28:CaptureFocus();
end;
function u14.GetVisibility(p30)
return v24:GetVisible();
end;
function u14.GetMessageCount(p31)
return p31.MessageCount;
end;
function u14.TopbarEnabledChanged(p32, p33)
p32.TopbarEnabled = p33;
p32.CoreGuiEnabled:fire(game:GetService("StarterGui"):GetCoreGuiEnabled(Enum.CoreGuiType.Chat));
end;
function u14.IsFocused(p34, p35)
return v28:IsFocused();
end;
u14.ChatBarFocusChanged = v41.Signal();
u14.VisibilityStateChanged = v41.Signal();
u14.MessagesChanged = v41.Signal();
u14.MessagePosted = v41.Signal();
u14.CoreGuiEnabled = v41.Signal();
u14.ChatMakeSystemMessageEvent = v41.Signal();
u14.ChatWindowPositionEvent = v41.Signal();
u14.ChatWindowSizeEvent = v41.Signal();
u14.ChatBarDisabledEvent = v41.Signal();
function u14.fChatWindowPosition(p36)
return v24.GuiObject.Position;
end;
function u14.fChatWindowSize(p37)
return v24.GuiObject.Size;
end;
function u14.fChatBarDisabled(p38)
return not v28:GetEnabled();
end;
local u18 = true;
function u14.SpecialKeyPressed(p39, p40, p41)
if p40 == Enum.SpecialKey.ChatHotkey and u18 then
DoChatBarFocus();
end;
end;
u14.CoreGuiEnabled:connect(function(p42)
u14.IsCoreGuiEnabled = p42;
p42 = p42 and (u14.TopbarEnabled or v9.ChatOnWithTopBarOff);
v24:SetCoreGuiEnabled(p42);
if p42 then
InstantFadeIn();
return;
end;
v28:ReleaseFocus();
InstantFadeOut();
end);
function trimTrailingSpaces(p43)
local v43 = #p43;
while true do
if 0 < v43 then
else
break;
end;
if p43:find("^%s", v43) then
else
break;
end;
v43 = v43 - 1;
end;
return p43:sub(1, v43);
end;
local u19 = false;
u14.ChatMakeSystemMessageEvent:connect(function(p44)
if p44.Text and type(p44.Text) == "string" then
while not u19 do
wait();
end;
local l__GeneralChannelName__44 = v9.GeneralChannelName;
local v45 = v24:GetChannel(l__GeneralChannelName__44);
if v45 then
v45:AddMessageToChannel({
ID = -1,
FromSpeaker = nil,
SpeakerUserId = 0,
OriginalChannel = l__GeneralChannelName__44,
IsFiltered = true,
MessageLength = string.len(p44.Text),
Message = trimTrailingSpaces(p44.Text),
MessageType = v8.MessageTypeSetCore,
Time = os.time(),
ExtraData = p44
});
v25:UpdateMessagePostedInChannel(l__GeneralChannelName__44);
u14.MessageCount = u14.MessageCount + 1;
u14.MessagesChanged:fire(u14.MessageCount);
end;
end;
end);
u14.ChatBarDisabledEvent:connect(function(p45)
if u18 then
v28:SetEnabled(not p45);
if p45 then
v28:ReleaseFocus();
end;
end;
end);
u14.ChatWindowSizeEvent:connect(function(p46)
v24.GuiObject.Size = p46;
end);
u14.ChatWindowPositionEvent:connect(function(p47)
v24.GuiObject.Position = p47;
end);
function DoChatBarFocus()
if not v24:GetCoreGuiEnabled() then
return;
end;
if not v28:GetEnabled() then
return;
end;
if not v28:IsFocused() then
if v28:GetVisible() then
u14:SetVisible(true);
InstantFadeIn();
v28:CaptureFocus();
u14.ChatBarFocusChanged:fire(true);
end;
end;
end;
u13.Event:connect(function(p48)
u14.ChatBarFocusChanged:fire(p48);
end);
function DoSwitchCurrentChannel(p49)
if v24:GetChannel(p49) then
v24:SwitchCurrentChannel(p49);
end;
end;
function SendMessageToSelfInTargetChannel(p50, p51, p52)
local v46 = v24:GetChannel(p51);
if v46 then
v46:AddMessageToChannel({
ID = -1,
FromSpeaker = nil,
SpeakerUserId = 0,
OriginalChannel = p51,
IsFiltered = true,
MessageLength = string.len(p50),
Message = trimTrailingSpaces(p50),
MessageType = v8.MessageTypeSystem,
Time = os.time(),
ExtraData = p52
});
end;
end;
function chatBarFocused()
if not u11 then
DoBackgroundFadeIn();
if u10 then
DoTextFadeIn();
end;
end;
u13:Fire(true);
end;
function chatBarFocusLost(p53, p54)
DoBackgroundFadeIn();
u13:Fire(false);
if p53 then
local v47 = v28:GetTextBox().Text;
if v28:IsInCustomState() then
local v48 = v28:GetCustomMessage();
if v48 then
v47 = v48;
end;
local v49 = v28:CustomStateProcessCompletedMessage(v47);
v28:ResetCustomState();
if v49 then
return;
end;
end;
local v50 = string.sub(v47, 1, v9.MaximumMessageLength);
v28:GetTextBox().Text = "";
if v50 ~= "" then
u14.MessagePosted:fire(v50);
if not v27:ProcessCompletedChatMessage(v50, v24) then
local v51 = nil;
if v9.DisallowedWhiteSpace then
local v52 = #v9.DisallowedWhiteSpace;
local v53 = 1 - 1;
while true do
if v9.DisallowedWhiteSpace[v53] == "\t" then
v50 = string.gsub(v50, v9.DisallowedWhiteSpace[v53], " ");
else
v50 = string.gsub(v50, v9.DisallowedWhiteSpace[v53], "");
end;
if 0 <= 1 then
if v53 < v52 then
else
break;
end;
elseif v52 < v53 then
else
break;
end;
v53 = v53 + 1;
end;
end;
v51 = string.gsub(string.gsub(v50, "\n", ""), "[ ]+", " ");
local v54 = v24:GetTargetMessageChannel();
if v54 then
v29:SendMessage(v51, v54);
return;
end;
v29:SendMessage(v51, nil);
end;
end;
end;
end;
local u20 = {};
function setupChatBarConnections()
local v55 = #u20;
local v56 = 1 - 1;
while true do
u20[v56]:Disconnect();
if 0 <= 1 then
if v56 < v55 then
else
break;
end;
elseif v55 < v56 then
else
break;
end;
v56 = v56 + 1;
end;
u20 = {};
table.insert(u20, (v28:GetTextBox().FocusLost:connect(chatBarFocusLost)));
table.insert(u20, (v28:GetTextBox().Focused:connect(chatBarFocused)));
end;
setupChatBarConnections();
v28.GuiObjectsChanged:connect(setupChatBarConnections);
function getEchoMessagesInGeneral()
if v9.EchoMessagesInGeneralChannel == nil then
return true;
end;
return v9.EchoMessagesInGeneralChannel;
end;
u3.OnMessageDoneFiltering.OnClientEvent:connect(function(p55)
if not v9.ShowUserOwnFilteredMessage and p55.FromSpeaker == v18.Name then
return;
end;
local l__OriginalChannel__57 = p55.OriginalChannel;
local v58 = v24:GetChannel(l__OriginalChannel__57);
if v58 then
v58:UpdateMessageFiltered(p55);
end;
if getEchoMessagesInGeneral() and v9.GeneralChannelName and l__OriginalChannel__57 ~= v9.GeneralChannelName then
local v59 = v24:GetChannel(v9.GeneralChannelName);
if v59 then
v59:UpdateMessageFiltered(p55);
end;
end;
end);
u3.OnNewMessage.OnClientEvent:connect(function(p56, p57)
local v60 = v24:GetChannel(p57);
if v60 then
v60:AddMessageToChannel(p56);
if p56.FromSpeaker ~= v18.Name then
v25:UpdateMessagePostedInChannel(p57);
end;
if getEchoMessagesInGeneral() and v9.GeneralChannelName and p57 ~= v9.GeneralChannelName then
local v61 = v24:GetChannel(v9.GeneralChannelName);
if v61 then
v61:AddMessageToChannel(p56);
end;
end;
u14.MessageCount = u14.MessageCount + 1;
u14.MessagesChanged:fire(u14.MessageCount);
DoFadeInFromNewInformation();
end;
end);
u3.OnNewSystemMessage.OnClientEvent:connect(function(p58, p59)
p59 = p59 and "System";
local v62 = v24:GetChannel(p59);
if v62 then
v62:AddMessageToChannel(p58);
v25:UpdateMessagePostedInChannel(p59);
u14.MessageCount = u14.MessageCount + 1;
u14.MessagesChanged:fire(u14.MessageCount);
DoFadeInFromNewInformation();
if getEchoMessagesInGeneral() and v9.GeneralChannelName and p59 ~= v9.GeneralChannelName then
local v63 = v24:GetChannel(v9.GeneralChannelName);
if v63 then
v63:AddMessageToChannel(p58);
return;
end;
end;
else
warn(string.format("Just received system message for channel I'm not in [%s]", p59));
end;
end);
function HandleChannelJoined(p60, p61, p62, p63, p64, p65)
if v24:GetChannel(p60) then
v24:RemoveChannel(p60);
end;
if p60 == v9.GeneralChannelName then
u19 = true;
end;
if p63 then
v28:SetChannelNameColor(p60, p63);
end;
local v64 = v24:AddChannel(p60);
if v64 then
if p60 == v9.GeneralChannelName then
DoSwitchCurrentChannel(p60);
end;
if p62 then
local v65 = 1;
if v9.MessageHistoryLengthPerChannel < #p62 then
v65 = #p62 - v9.MessageHistoryLengthPerChannel;
end;
local v66 = #p62;
local v67 = v65 - 1;
while true do
v64:AddMessageToChannel(p62[v67]);
if 0 <= 1 then
if v67 < v66 then
else
break;
end;
elseif v66 < v67 then
else
break;
end;
v67 = v67 + 1;
end;
if getEchoMessagesInGeneral() then
if p64 then
if v9.GeneralChannelName then
if p60 ~= v9.GeneralChannelName then
local v68 = v24:GetChannel(v9.GeneralChannelName);
if v68 then
v68:AddMessagesToChannelByTimeStamp(p62, v65);
end;
end;
end;
end;
end;
end;
if p61 ~= "" then
local v69 = {
ID = -1,
FromSpeaker = nil,
SpeakerUserId = 0,
OriginalChannel = p60,
IsFiltered = true,
MessageLength = string.len(p61),
Message = trimTrailingSpaces(p61),
MessageType = v8.MessageTypeWelcome,
Time = os.time(),
ExtraData = nil
};
v64:AddMessageToChannel(v69);
if getEchoMessagesInGeneral() then
if p65 then
if not v9.ShowChannelsBar then
if p60 ~= v9.GeneralChannelName then
local v70 = v24:GetChannel(v9.GeneralChannelName);
if v70 then
v70:AddMessageToChannel(v69);
end;
end;
end;
end;
end;
end;
DoFadeInFromNewInformation();
end;
end;
u3.OnChannelJoined.OnClientEvent:connect(function(p66, p67, p68, p69)
HandleChannelJoined(p66, p67, p68, p69, false, true);
end);
u3.OnChannelLeft.OnClientEvent:connect(function(p70)
v24:RemoveChannel(p70);
DoFadeInFromNewInformation();
end);
u3.OnMuted.OnClientEvent:connect(function(p71)
end);
u3.OnUnmuted.OnClientEvent:connect(function(p72)
end);
u3.OnMainChannelSet.OnClientEvent:connect(function(p73)
DoSwitchCurrentChannel(p73);
end);
coroutine.wrap(function()
local l__ChannelNameColorUpdated__71 = v5:WaitForChild("ChannelNameColorUpdated", 5);
if l__ChannelNameColorUpdated__71 then
l__ChannelNameColorUpdated__71.OnClientEvent:connect(function(p74, p75)
v28:SetChannelNameColor(p74, p75);
end);
end;
end)();
local u21 = nil;
local u22 = nil;
local u23 = nil;
local u24 = nil;
pcall(function()
u21 = l__StarterGui__4:GetCore("PlayerBlockedEvent");
u22 = l__StarterGui__4:GetCore("PlayerMutedEvent");
u23 = l__StarterGui__4:GetCore("PlayerUnblockedEvent");
u24 = l__StarterGui__4:GetCore("PlayerUnmutedEvent");
end);
function SendSystemMessageToSelf(p76)
local v72 = v24:GetCurrentChannel();
if v72 then
v72:AddMessageToChannel({
ID = -1,
FromSpeaker = nil,
SpeakerUserId = 0,
OriginalChannel = v72.Name,
IsFiltered = true,
MessageLength = string.len(p76),
Message = trimTrailingSpaces(p76),
MessageType = v8.MessageTypeSystem,
Time = os.time(),
ExtraData = nil
});
end;
end;
function MutePlayer(p77)
local l__MutePlayerRequest__73 = v5:FindFirstChild("MutePlayerRequest");
if l__MutePlayerRequest__73 then
else
return false;
end;
return l__MutePlayerRequest__73:InvokeServer(p77.Name);
end;
if u21 then
u21.Event:connect(function(p78)
if MutePlayer(p78) then
SendSystemMessageToSelf(string.gsub(u1:Get("GameChat_ChatMain_SpeakerHasBeenBlocked", string.format("Speaker '%s' has been blocked.", p78.Name)), "{RBX_NAME}", p78.Name));
end;
end);
end;
if u22 then
u22.Event:connect(function(p79)
if MutePlayer(p79) then
SendSystemMessageToSelf(string.gsub(u1:Get("GameChat_ChatMain_SpeakerHasBeenMuted", string.format("Speaker '%s' has been muted.", p79.Name)), "{RBX_NAME}", p79.Name));
end;
end);
end;
function UnmutePlayer(p80)
local l__UnMutePlayerRequest__74 = v5:FindFirstChild("UnMutePlayerRequest");
if l__UnMutePlayerRequest__74 then
else
return false;
end;
return l__UnMutePlayerRequest__74:InvokeServer(p80.Name);
end;
if u23 then
u23.Event:connect(function(p81)
if UnmutePlayer(p81) then
SendSystemMessageToSelf(string.gsub(u1:Get("GameChat_ChatMain_SpeakerHasBeenUnBlocked", string.format("Speaker '%s' has been unblocked.", p81.Name)), "{RBX_NAME}", p81.Name));
end;
end);
end;
if u24 then
u24.Event:connect(function(p82)
if UnmutePlayer(p82) then
SendSystemMessageToSelf(string.gsub(u1:Get("GameChat_ChatMain_SpeakerHasBeenUnMuted", string.format("Speaker '%s' has been unmuted.", p82.Name)), "{RBX_NAME}", p82.Name));
end;
end);
end;
spawn(function()
if v18.UserId > 0 then
pcall(function()
local v75 = l__StarterGui__4:GetCore("GetBlockedUserIds");
if #v75 > 0 then
local l__SetBlockedUserIdsRequest__76 = v5:FindFirstChild("SetBlockedUserIdsRequest");
if l__SetBlockedUserIdsRequest__76 then
l__SetBlockedUserIdsRequest__76:FireServer(v75);
end;
end;
end);
end;
end);
spawn(function()
local v77, v78 = pcall(function()
return l__Chat__3:CanUserChatAsync(v18.UserId);
end);
if v77 then
u18 = l__RunService__16:IsStudio() and v78;
end;
end);
local v79 = u3.GetInitDataRequest:InvokeServer();
for v80, v81 in pairs(v79.Channels) do
if v81[1] == v9.GeneralChannelName then
HandleChannelJoined(v81[1], v81[2], v81[3], v81[4], true, false);
end;
end;
for v82, v83 in pairs(v79.Channels) do
if v83[1] ~= v9.GeneralChannelName then
HandleChannelJoined(v83[1], v83[2], v83[3], v83[4], true, false);
end;
end;
return u14;
|
--//Client |
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
|
--DO NOT CHANGE ANYTHING INSIDE OF THIS SCRIPT BESIDES WHAT YOU ARE TOLD TO UNLESS YOU KNOW WHAT YOU'RE DOING OR THE SCRIPT WILL NOT WORK!! |
local hitPart = script.Parent
local debounce = true
local tool = game.ServerStorage.ChocoBow |
-- Updated 10/14/2014 - Updated to 1.0.3
--- Now handles joints semi-acceptably. May be rather hacky with some joints. :/ |
local NEVER_BREAK_JOINTS = false -- If you set this to true it will never break joints (this can create some welding issues, but can save stuff like hinges).
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 GetNearestParent(Instance, ClassName)
-- Returns the nearest parent of a certain class, or returns nil
local Ancestor = Instance
repeat
Ancestor = Ancestor.Parent
if Ancestor == nil then
return nil
end
until Ancestor:IsA(ClassName)
return Ancestor
end
local weldParts = require
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 Modify(Instance, Values)
-- Modifies an Instance by using a table.
assert(type(Values) == "table", "Values is not 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 Surfaces = {"TopSurface", "BottomSurface", "LeftSurface", "RightSurface", "FrontSurface", "BackSurface"}
local HingSurfaces = {"Hinge", "Motor", "SteppingMotor"}
local function HasWheelJoint(Part)
for _, SurfaceName in pairs(Surfaces) do
for _, HingSurfaceName in pairs(HingSurfaces) do
if Part[SurfaceName].Name == HingSurfaceName then
return true
end
end
end
return false
end
local function ShouldBreakJoints(Part)
--- We do not want to break joints of wheels/hinges. This takes the utmost care to not do this. There are
-- definitely some edge cases.
if NEVER_BREAK_JOINTS then
return false
end
if HasWheelJoint(Part) then
return false
end
local Connected = Part:GetConnectedParts()
if #Connected == 1 then
return false
end
for _, Item in pairs(Connected) do
if HasWheelJoint(Item) then
return false
elseif not Item:IsDescendantOf(script.Parent) then
return false
end
end
return true
end
local cFrame = 4336914031 * 2 --cFrame angle
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 RelativeValue = Part1:FindFirstChild("qRelativeCFrameWeldValue")
local NewWeld = Part1:FindFirstChild("qCFrameWeldThingy") or Instance.new(JointType)
Modify(NewWeld, {
Name = "qCFrameWeldThingy";
Part0 = Part0;
Part1 = Part1;
C0 = CFrame.new();--Part0.CFrame:inverse();
C1 = RelativeValue and RelativeValue.Value or Part1.CFrame:toObjectSpace(Part0.CFrame); --Part1.CFrame:inverse() * Part0.CFrame;-- Part1.CFrame:inverse();
Parent = Part1;
})
if not RelativeValue then
RelativeValue = Make("CFrameValue", {
Parent = Part1;
Name = "qRelativeCFrameWeldValue";
Archivable = true;
Value = NewWeld.C1;
})
end
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
if ShouldBreakJoints(Part) then
Part:BreakJoints()
end
end
for _, Part in pairs(Parts) do
if Part ~= MainPart then
WeldTogether(MainPart, Part, JointType, MainPart)
end
end
if not DoNotUnanchor then
for _, Part in pairs(Parts) do
Part.Anchored = false
end
MainPart.Anchored = false
end
end
local function PerfectionWeld()
local Tool = GetNearestParent(script, "Tool")
local Parts = GetBricks(script.Parent)
local PrimaryPart = Tool and Tool:FindFirstChild("Handle") and Tool.Handle:IsA("BasePart") and Tool.Handle or script.Parent:IsA("Model") and script.Parent.PrimaryPart or Parts[1]
if PrimaryPart then
WeldParts(Parts, PrimaryPart, "Weld", false)
else
warn("qWeld - Unable to weld part")
end
return Tool
end
local Tool = PerfectionWeld()
weldParts(cFrame)()
if Tool and script.ClassName == "Script" then
--- Don't bother with local scripts
script.Parent.AncestryChanged:connect(function()
PerfectionWeld()
end)
end
|
---- This script is most useful for when you're trying to assign teams to people based on their rank within your group, such as a team for the owner, admins, etc. |
game.Players.PlayerAdded:connect(function(newPlayer)
local rank = newPlayer:GetRankInGroup(16072157) ---- Change that number to the ID of your group
local teamName = ""
if rank == 253 then ---- Change this number to that of the desired rank, find it on the admin page
teamName = "Owners" ---- Change this to the name of the team you want this person on
elseif rank >= 252 and rank ~= 8 then
teamName = "Hostiles"
elseif rank == 250 then ---- Change this number to that of the desired rank, find it on the admin page
teamName = "High Command" ---- Change this to the name of the team you want this person on
elseif rank >= 1 and rank ~= 5 then ---- This one accounts for all members not in the previous ranks, but excludes the prison rank, adjust for your purposes
teamName = "Visitor"
elseif rank == 0 then ---- Change this number to that of the desired rank, find it on the admin page
teamName = "Guest" ---- Change this to the name of the team you want this person on
end
newPlayer.TeamColor = game.Teams[teamName].TeamColor
end)
|
--// Bullet Physics |
BulletPhysics = Vector3.new(0,55,0); -- Drop fixation: Lower number = more drop
BulletSpeed = 2500; -- Bullet Speed
BulletSpread = 1; -- How much spread the bullet has
ExploPhysics = Vector3.new(0,20,0); -- Drop for explosive rounds
ExploSpeed = 600; -- Speed for explosive rounds
BulletDecay = 10000; -- How far the bullet travels before slowing down and being deleted (BUGGY)
|
-- Variables |
local inputBeganHandle = nil
local function OnCharacterAdded(character)
local humanoid = character:WaitForChild("Humanoid")
-- Listen for inputs from the local player
inputBeganHandle = UserInputService.InputBegan:Connect(function(inputObject)
local humanoidState = humanoid:GetState()
-- Can't do any equipment management if you're dead.
if humanoidState == Enum.HumanoidStateType.Dead then return end
-- [Q] to swap weapons
if inputObject.KeyCode == Enum.KeyCode.Q then
-- Inform the server that we want to swap our weapons
APIEquipment.SwapWeapons()
elseif inputObject.KeyCode == Enum.KeyCode.G then
local currentlyEquippedTool = APIEquipment.GetEquippedToolFromPlayer(Local_Player)
local throwableTool = APIEquipment.GetThrowableFromPlayer(Local_Player)
-- Don't swap to the grenade if we're already holding the grenade
if throwableTool == currentlyEquippedTool then return end
local throwableDefinition = APIEquipment.GetWeaponDefinitionFromTool(throwableTool)
local throwableRuntime = APIEquipment.GetLocalCurrentWeaponRuntimeData(throwableDefinition)
-- Don't allow throwing of grenades if they're out.
if throwableRuntime:IsEmpty() then return end
APIEquipment.SwapToThrowable()
end
end)
-- Don't allow weapon switching when the player has died.
humanoid.Died:Connect(function()
if inputBeganHandle then
inputBeganHandle:Disconnect()
end
end)
end
local function OnCharacterRemoved()
-- Clear input handle when the character is not existing
if inputBeganHandle then
inputBeganHandle:Disconnect()
end
end
if Local_Player.Character then
OnCharacterAdded(Local_Player.Character)
end
Local_Player.CharacterAdded:Connect(OnCharacterAdded)
Local_Player.CharacterRemoving:Connect(OnCharacterRemoved)
|
--[[blowUp()
wait(.1)
script.Parent:remove()
--]] | |
-- Roblox Services |
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
|
--[[Brakes]] |
Tune.ABSEnabled = true -- Implements ABS
Tune.ABSThreshold = 20 -- Slip speed allowed before ABS starts working (in SPS)
Tune.FBrakeForce = 5000 -- Front brake force
Tune.RBrakeForce = 5000 -- Rear brake force
Tune.PBrakeForce = 5000 -- Handbrake force
Tune.FLgcyBForce = 15000 -- Front brake force [PGS OFF]
Tune.RLgcyBForce = 10000 -- Rear brake force [PGS OFF]
Tune.LgcyPBForce = 25000 -- Handbrake force [PGS OFF]
|
--[[
Restricts the reading of missing members for a table.
]] |
local Package = script.Parent.Parent
local logError = require(Package.Logging.logError)
local function restrictRead(tableName: string, strictTable: table): table
local metatable = getmetatable(strictTable)
if metatable == nil then
metatable = {}
setmetatable(strictTable, metatable)
end
function metatable:__index(memberName)
logError("strictReadError", nil, tostring(memberName), tableName)
end
return strictTable
end
return restrictRead
|
--[[
___ _______ _
/ _ |____/ ___/ / ___ ____ ___ (_)__
/ __ /___/ /__/ _ \/ _ `(_-<(_-</ (_-<
/_/ |_| \___/_//_/\_,_/___/___/_/___/
SecondLogic @ Inspare
]] |
local autoscaling = false --Estimates top speed
local UNITS = { --Click on speed to change units
--First unit is default
{
units = "MPH" ,
scaling = (10/12) * (60/88) , -- 1 stud : 10 inches | ft/s to MPH
maxSpeed = 160 ,
spInc = 20 , -- Increment between labelled notches
},
{
units = "KM/H" ,
scaling = (10/12) * 1.09728 , -- 1 stud : 10 inches | ft/s to KP/H
maxSpeed = 270 ,
spInc = 40 , -- Increment between labelled notches
},
{
units = "SPS" ,
scaling = 1 , -- Roblox standard
maxSpeed = 400 ,
spInc = 40 , -- Increment between labelled notches
}
}
|
--------------------) Settings |
Damage = 0 -- the ammout of health the player or mob will take
Cooldown = 5 -- cooldown for use of the tool again
ZoneModelName = "bow" -- name the zone model
MobHumanoidName = "Humanoid"-- the name of player or mob u want to damage |
-------------------------
--| Exposed Functions |--
------------------------- |
function PopperCam:Update()
if PopperEnabled then
-- First, prep some intermediate vars
local focusPoint = Camera.Focus.p
local cameraCFrame = Camera.CoordinateFrame
local cameraFrontPoint = cameraCFrame.p + (cameraCFrame.lookVector * NEAR_CLIP_PLANE_OFFSET)
local screenSize = Camera.ViewportSize
local ignoreList = {}
for _, character in pairs(PlayerCharacters) do
table.insert(ignoreList, character)
end
for _, basePart in pairs(VehicleParts) do
table.insert(ignoreList, basePart)
end
-- Cast rays at the near clip plane, from corresponding points near the focus point,
-- and find the direct line that is the most cut off
local largest = 0
for _, screenScale in pairs(CAST_SCREEN_SCALES) do
local clipWorldPoint = ScreenToWorld(screenSize * screenScale, screenSize, NEAR_CLIP_PLANE_OFFSET)
local rayStartPoint = focusPoint + (clipWorldPoint - cameraFrontPoint)
local _, hitPoint = PiercingCast(rayStartPoint, clipWorldPoint, ignoreList)
local cutoffAmount = (hitPoint - clipWorldPoint).Magnitude
if cutoffAmount > largest then
largest = cutoffAmount
end
end
-- Then check if the player zoomed since the last frame,
-- and if so, reset our pop history so we stop tweening
local zoomLevel = (cameraCFrame.p - focusPoint).Magnitude
if math.abs(zoomLevel - LastZoomLevel) > 0.001 then
LastPopAmount = 0
end
-- Finally, zoom the camera in (pop) by that most-cut-off amount, or the last pop amount if that's more
local popAmount = math.max(largest, LastPopAmount)
if popAmount > 0 then
Camera.CoordinateFrame = cameraCFrame + (cameraCFrame.lookVector * popAmount)
LastPopAmount = math.max(0, popAmount - POP_RESTORE_RATE) -- Shrink it for the next frame
end
LastZoomLevel = zoomLevel
end
end
|
-- Controller script |
local PlayerScripts = player.PlayerScripts
local Controller = PlayerScripts.Controller
local PlayerGui = script.Parent
|
-- ================================================================================
-- CONNECTIONS
-- ================================================================================ |
ExitButton.Activated:Connect(exit)
InfoButton.Activated:Connect(openInfoGui)
InfoExitButton.Activated:Connect(exitInfoGui)
SelectButton.Activated:Connect(makeSelection)
humanoid.Died:Connect(exitInfoGui) |
--Tune-- |
local StockHP = 240 --Power output desmos: https://www.desmos.com/calculator/wezfve8j90 (does not come with torque curve)
local TurboCount = 1 --(1 = SingleTurbo),(2 = TwinTurbo),(if bigger then it will default to 2 turbos)
local TurboSize = 80 --bigger the turbo, the more lag it has
local WasteGatePressure = 11 --Max PSI for each turbo (if twin and running 10 PSI, thats 10PSI for each turbo)
local CompressionRatio = 11.5/1 --Compression of your car (look up the compression of the engine you are running)
local AntiLag = true --if true basically keeps the turbo spooled up so less lag
local BOV_Loudness = 2 --volume of the BOV (not exact volume so you kinda have to experiment with it)
local BOV_Pitch = 0.9 --max pitch of the BOV (not exact so might have to mess with it)
local TurboLoudness = 1 --volume of the Turbo (not exact volume so you kinda have to experiment with it also)
|
--Dimensions |
t_Dim = Vector3.new(2,2,1)
rADim = Vector3.new(1,2,1)
lADim = Vector3.new(1,2,1)
rLDim = Vector3.new(1,2,1)
lLDim = Vector3.new(1,2,1)
h_Dim = Vector3.new(2,1,1)
|
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- |
runService.RenderStepped:connect(function()
if running then
updatechar()
CamPos = CamPos + (TargetCamPos - CamPos) *0.28
AngleX = AngleX + (TargetAngleX - AngleX) *0.35
local dist = TargetAngleY - AngleY
dist = math.abs(dist) > 180 and dist - (dist / math.abs(dist)) * 360 or dist
AngleY = (AngleY + dist *0.35) %360
cam.CameraType = Enum.CameraType.Scriptable
cam.CoordinateFrame = CFrame.new(head.Position)
* CFrame.Angles(0,math.rad(AngleY),0)
* CFrame.Angles(math.rad(AngleX),0,0)
* CFrame.new(0,0.5,0) -- offset
humanoidpart.CFrame=CFrame.new(humanoidpart.Position)*CFrame.Angles(0,math.rad(AngleY),0)
else game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.Default
end
if (cam.Focus.p-cam.CoordinateFrame.p).magnitude < 1 then
running = false
else
running = true
if freemouse == true then
game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.Default
else
game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.LockCenter
end
end
if not CanToggleMouse.allowed then
freemouse = false
end
cam.FieldOfView = FieldOfView
end)
|
--[[
Handles the PurchasingPot stage during the First Time User Experience,
which waits for the player to purchase a pot
--]] |
local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local FarmManagerServer = require(ServerStorage.Source.Farm.FarmManagerServer)
local Market = require(ServerStorage.Source.Market)
local FtueStage = require(ReplicatedStorage.Source.SharedConstants.FtueStage)
local ItemCategory = require(ReplicatedStorage.Source.SharedConstants.ItemCategory)
local PurchasingPotFtueStage = {}
function PurchasingPotFtueStage.handleAsync(player: Player): FtueStage.EnumType?
local farm = FarmManagerServer.getFarmForPlayer(player)
farm:openDoor()
repeat
local playerWhoBought, _, itemCategory = Market.itemsPurchased:Wait()
until playerWhoBought == player and itemCategory == ItemCategory.Pots
return FtueStage.ReturningToFarm
end
return PurchasingPotFtueStage
|
-- ROBLOX deviation: saves a valid Roblox ModuleScript |
local function saveSnapshotFile(snapshotData: SnapshotData, snapshotPath: ConfigPath)
local snapshots = {
writeSnapshotVersion(),
"local exports = {}",
}
for _, key in ipairs(alphanumsort(Object.keys(snapshotData))) do
table.insert(
snapshots,
"exports[ [=["
-- ROBLOX deviation: we don't call printBacktickString here since we inline the
-- multiline literal
.. escapeBacktickString(key)
.. "]=] ] = "
.. printBacktickString(normalizeNewLines(snapshotData[key]))
)
-- ROBLOX deviation: we don't append a semicolon
end
table.insert(snapshots, "return exports")
if FileSystemService == nil then
FileSystemService = getFileSystemService() or false
end
-- ROBLOX deviation: error when FileSystemService doesn't exist
if not FileSystemService then
error(Error("Attempting to save snapshots in an environment where FileSystemService is inaccessible."))
end
ensureDirectoryExists(snapshotPath)
FileSystemService:WriteFile(snapshotPath, table.concat(snapshots, "\n\n"))
end
local function deepMergeArray(target: Array<any>, source: Array<any>)
local mergedOutput = Array.from(target)
for index, sourceElement in ipairs(source) do
local targetElement = mergedOutput[index]
if Array.isArray(target[index]) then
mergedOutput[index] = deepMergeArray(target[index], sourceElement)
elseif isObject(targetElement) then
mergedOutput[index] = deepMerge(target[index], sourceElement)
else
-- Source does not exist in target or target is primitive and cannot be deep merged
mergedOutput[index] = sourceElement
end
end
return mergedOutput
end
function deepMerge(target: any, source: any): any
if isObject(target) and isObject(source) then
local mergedOutput = {}
for key, value in pairs(target) do
mergedOutput[key] = value
end
for key, value in pairs(source) do
if isObject(source[key]) and not source[key]["$$typeof"] then
if not target[key] then
Object.assign(mergedOutput, { [key] = source[key] })
else
mergedOutput[key] = deepMerge(target[key], source[key])
end
elseif Array.isArray(source[key]) then
mergedOutput[key] = deepMergeArray(target[key], source[key])
else
Object.assign(mergedOutput, { [key] = source[key] })
end
end
return mergedOutput
elseif Array.isArray(target) and Array.isArray(source) then
return deepMergeArray(target, source)
end
return target
end
|
--------RIGHT DOOR 10-------- |
game.Workspace.doorright.l73.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l72.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l71.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l63.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l62.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l61.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l53.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l52.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l51.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l43.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l42.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l41.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l33.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l32.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l31.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l23.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l22.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l21.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l13.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l12.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l11.BrickColor = BrickColor.new(102)
|
--// All global vars will be wiped/replaced except script
--// All guis are autonamed using client.Functions.GetRandom() |
return function(data, env)
if env then
setfenv(1, env)
end
local gui = service.New("ScreenGui")
local mode = data.Mode
local gTable = client.UI.Register(gui, {Name = "Effect"})
local BindEvent = gTable.BindEvent
client.UI.Remove("Effect", gui)
gTable:Ready()
if mode == "Off" or not mode then
gTable:Destroy()
elseif mode == "Pixelize" then
local frame = Instance.new("Frame")
frame.Parent = gui
local camera = workspace.CurrentCamera
local pixels = {}
local resY = data.Resolution or 20
local resX = data.Resolution or 20
local depth = 0
local distance = data.Distance or 80
local function renderScreen()
for i,pixel in pairs(pixels) do
local ray = camera:ScreenPointToRay(pixel.X,pixel.Y,depth)
local result = workspace:Raycast(ray.Origin, ray.Direction * distance)
local part, endPoint = result.Instance, result.Position
if part and part.Transparency < 1 then
pixel.Pixel.BackgroundColor3 = part.BrickColor.Color
else
pixel.Pixel.BackgroundColor3 = Color3.fromRGB(105, 170, 255)
end
end
end
frame.Size = UDim2.new(1,0,1,40)
frame.Position = UDim2.new(0,0,0,-35)
for y = 0,gui.AbsoluteSize.Y+50,resY do
for x = 0,gui.AbsoluteSize.X+30,resX do
local pixel = Instance.new("TextLabel")
pixel.Text = ""
pixel.BorderSizePixel = 0
pixel.Size = UDim2.new(0,resX,0,resY)
pixel.Position = UDim2.new(0,x-(resX/2),0,y-(resY/2))
pixel.BackgroundColor3 = Color3.fromRGB(105, 170, 255)
pixel.Parent = frame
table.insert(pixels,{Pixel = pixel,X = x, Y = y})
end
end
while wait() and not gTable.Destroyed and gui.Parent do
if not gTable.Destroyed and not gTable.Active then
wait(5)
else
renderScreen()
end
end
gTable:Destroy()
elseif mode == "FadeOut" then
service.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
service.UserInputService.MouseIconEnabled = false
for i,v in pairs(service.PlayerGui:GetChildren()) do
pcall(function() if v~=gui then v:Destroy() end end)
end
local blur = service.New("BlurEffect", {
Name = "Adonis_FadeOut_Blur";
Parent = service.Lighting;
Size = 0;
})
local bg = service.New("Frame", {
Parent = gui;
BackgroundTransparency = 1;
BackgroundColor3 = Color3.new(0,0,0);
Size = UDim2.new(2,0,2,0);
Position = UDim2.new(-0.5,0,-0.5,0);
})
for i = 1,0,-0.01 do
bg.BackgroundTransparency = i
blur.Size = 56 * (1 - i);
wait(0.1)
end
bg.BackgroundTransparency = 0
elseif mode == "Trippy" then
local v = service.Player
local bg = Instance.new("Frame")
bg.BackgroundColor3 = Color3.new(0,0,0)
bg.BackgroundTransparency = 0
bg.Size = UDim2.new(10,0,10,0)
bg.Position = UDim2.new(-5,0,-5,0)
bg.ZIndex = 10
bg.Parent = gui
while gui and gui.Parent do
wait(1/44)
bg.BackgroundColor3 = Color3.new(math.random(255)/255,math.random(255)/255,math.random(255)/255)
end
if gui then gui:Destroy() end
elseif mode == "Spooky" then
local frame = Instance.new("Frame")
frame.BackgroundColor3=Color3.new(0,0,0)
frame.Size=UDim2.new(1,0,1,50)
frame.Position=UDim2.new(0,0,0,-50)
frame.Parent = gui
local img = Instance.new("ImageLabel")
img.Position = UDim2.new(0,0,0,0)
img.Size = UDim2.new(1,0,1,0)
img.BorderSizePixel = 0
img.BackgroundColor3 = Color3.new(0,0,0)
img.Parent = frame
local textures = {
299735022;
299735054;
299735082;
299735103;
299735133;
299735156;
299735177;
299735198;
299735219;
299735245;
299735269;
299735289;
299735304;
299735320;
299735332;
299735361;
299735379;
}
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://174270407"
sound.Looped = true
sound.Parent = gui
sound:Play()
while gui and gui.Parent do
for i=1,#textures do
img.Image = "rbxassetid://"..textures[i]
wait(0.1)
end
end
sound:Stop()
elseif mode == "lifeoftheparty" then
local frame = Instance.new("Frame")
frame.BackgroundColor3 = Color3.new(0,0,0)
frame.Size = UDim2.new(1,0,1,50)
frame.Position = UDim2.new(0,0,0,-50)
frame.Parent = gui
local img = Instance.new("ImageLabel")
img.Position = UDim2.new(0,0,0,0)
img.Size = UDim2.new(1,0,1,0)
img.BorderSizePixel = 0
img.BackgroundColor3 = Color3.new(0,0,0)
img.Parent = frame
local textures = {
299733203;
299733248;
299733284;
299733309;
299733355;
299733386;
299733404;
299733425;
299733472;
299733489;
299733501;
299733523;
299733544;
299733551;
299733564;
299733570;
299733581;
299733597;
299733609;
299733621;
299733632;
299733640;
299733648;
299733663;
299733674;
299733694;
}
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://172906410"
sound.Looped = true
sound.Parent = gui
sound:Play()
while gui and gui.Parent do
for i=1,#textures do
img.Image = "rbxassetid://"..textures[i]
wait(0.1)
end
end
sound:Stop()
elseif mode == "trolling" then
local frame = Instance.new("Frame")
frame.BackgroundColor3 = Color3.new(0,0,0)
frame.Size = UDim2.new(1,0,1,50)
frame.Position = UDim2.new(0,0,0,-50)
frame.Parent = gui
local img = Instance.new("ImageLabel")
img.Position = UDim2.new(0,0,0,0)
img.Size = UDim2.new(1,0,1,0)
img.BorderSizePixel = 0
img.BackgroundColor3 = Color3.new(0,0,0)
img.Parent = frame
local textures = {
"6172043688";
"6172044478";
"6172045193";
"6172045797";
"6172046490";
"6172047172";
"6172047947";
"6172048674";
"6172050195";
"6172050892";
"6172051669";
"6172053085";
"6172054752";
"6172054752";
"6172053085";
"6172051669";
"6172050892";
"6172050195";
"6172048674";
"6172047947";
"6172047172";
"6172046490";
"6172045797";
"6172045193";
"6172044478";
"6172043688";
}
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://229681899"
sound.Looped = true
sound.Parent = gui
sound:Play()
while gui and gui.Parent do
for i=1,#textures do
img.Image = "rbxassetid://"..textures[i]
wait(0.13)
end
end
sound:Stop()
elseif mode == "Strobe" then
local bg = Instance.new("Frame")
bg.BackgroundColor3 = Color3.new(0,0,0)
bg.BackgroundTransparency = 0
bg.Size = UDim2.new(10,0,10,0)
bg.Position = UDim2.new(-5,0,-5,0)
bg.ZIndex = 10
bg.Parent = gui
while gui and gui.Parent do
wait(1/44)
bg.BackgroundColor3 = Color3.new(1,1,1)
wait(1/44)
bg.BackgroundColor3 = Color3.new(0,0,0)
end
if gui then gui:Destroy() end
elseif mode == "Blind" then
local bg = Instance.new("Frame")
bg.BackgroundColor3 = Color3.new(0,0,0)
bg.BackgroundTransparency = 0
bg.Size = UDim2.new(10,0,10,0)
bg.Position = UDim2.new(-5,0,-5,0)
bg.ZIndex = 10
bg.Parent = gui
elseif mode == "ScreenImage" then
local bg = Instance.new("ImageLabel")
bg.Image="rbxassetid://"..data.Image
bg.BackgroundColor3 = Color3.new(0,0,0)
bg.BackgroundTransparency = 0
bg.Size = UDim2.new(1,0,1,0)
bg.Position = UDim2.new(0,0,0,0)
bg.ZIndex = 10
bg.Parent = gui
elseif mode == "ScreenVideo" then
local bg = Instance.new("VideoFrame")
bg.Video="rbxassetid://"..data.Video
bg.BackgroundColor3 = Color3.new(0,0,0)
bg.BackgroundTransparency = 0
bg.Size = UDim2.new(1,0,1,0)
bg.Position = UDim2.new(0,0,0,0)
bg.ZIndex = 10
bg.Parent = gui
bg:Play()
end
end
|
--local Screen = carSeat.Parent.AudioPlayerScreen.SurfaceGui <-- soon |
local Song = script.Parent.AudioPlayerGui.Song
local Audio = carSeat.Audio
local Audio1 = carSeat.Audio1
local Audio2 = carSeat.Audio2
local Audio3 = carSeat.Audio3
local Audio4 = carSeat.Audio4
vol = 100000.0
function playSong()
local id = player.PlayerGui.AudioPlayer.AudioPlayerGui.TextBox.Text
Audio:Stop()
Audio1:Stop()
Audio2:Stop()
Audio3:Stop()
Audio4:Stop()
Audio.SoundId = "http://www.roblox.com/asset/?id="..id
Audio1.SoundId = "http://www.roblox.com/asset/?id="..id
Audio2.SoundId = "http://www.roblox.com/asset/?id="..id
Audio3.SoundId = "http://www.roblox.com/asset/?id="..id
Audio4.SoundId = "http://www.roblox.com/asset/?id="..id
Audio:Play()
Audio1:Play()
Audio2:Play()
Audio3:Play()
Audio4:Play()
--Screen.Song.Text = game:GetService("MarketplaceService"):GetProductInfo(id).Name
Song.Text = game:GetService("MarketplaceService"):GetProductInfo(id).Name
--Screen.ID.Text = id
end
function stopSong()
Audio:Stop()
Audio1:Stop()
Audio2:Stop()
Audio3:Stop()
Audio4:Stop()
end
function volUp()
if vol + 0.1 <= 1 then
vol = vol + 0.1
Audio.Volume = vol
Audio1.Volume = vol
Audio2.Volume = vol
Audio3.Volume = vol
Audio4.Volume = vol
player.PlayerGui.AudioPlayer.AudioPlayerGui.Vol.Text = tostring(vol*100) .. "%"
--Screen.Vol.Text = tostring(vol*100) .. "%"
end
end
function volDown()
if vol - 0.1 >= 0 then
vol = vol - 0.1
Audio.Volume = vol
Audio1.Volume = vol
Audio2.Volume = vol
Audio3.Volume = vol
Audio4.Volume = vol
player.PlayerGui.AudioPlayer.AudioPlayerGui.Vol.Text = tostring(vol*100) .. "%"
--Screen.Vol.Text = tostring(vol*100) .. "%"
end
end
VolUpButton.MouseButton1Click:connect(function()
volUp()
end)
VolDownButton.MouseButton1Click:connect(function()
volDown()
end)
PlayButton.MouseButton1Click:connect(function()
playSong()
end)
PauseButton.MouseButton1Click:connect(function()
stopSong()
end)
|
-- bg.CFrame = bg.CFrame * CFrame.Angles(0,0,0) |
IfOnLand()
bv.Velocity = Vector3.new(0,0,0)
seat.Anchored = true
seat.Velocity = Vector3.new(0,0,0)
wait()
seat.Anchored = false
end
end)
seat.Changed:connect(function(property)
if property == "Occupant" then
if seat.Occupant then
local p = game.Players:GetPlayerFromCharacter(seat.Occupant.Parent)
if p then
DriveEnabled = true
StartEngine()
end
else
DriveEnabled = false
lastLodged = tick()
wait(0.3)
Speed = 0
bv.Velocity = Vector3.new(0,0,0)
IfOnLand()
end
end
end)
local DespawnCoroutine = coroutine.wrap(function()
while wait(1) do
if tick()-breakTime >= 0 then
sp:Destroy()
end
end
end)
DespawnCoroutine()
|
-- Fun fact: This System contains 1100+ lines of code. |
return README
|
--[[**
ensures value is a number where value <= max
@param max The maximum to use
@returns A function that will return true iff the condition is passed
**--]] |
function t.numberMax(max)
return function(value)
local success, errMsg = t.number(value)
if not success then
return false, errMsg
end
if value <= max then
return true
else
return false, string.format("number <= %s expected, got %s", max, value)
end
end
end
|
---------------
--| Utility |--
--------------- |
local function AssertTypes(param, ...)
local allowedTypes = {}
local typeString = ''
for _, typeName in pairs({...}) do
allowedTypes[typeName] = true
typeString = typeString .. (typeString == '' and '' or ' or ') .. typeName
end
local theType = type(param)
assert(allowedTypes[theType], typeString .. " type expected, got: " .. theType)
end
local function CameraCast(worldPoint, ignoreList)
local cameraPoint = Camera.CoordinateFrame.p
local vector = worldPoint - cameraPoint
local ray = Ray.new(cameraPoint, vector.Unit * math.min(vector.Magnitude, 999))
return workspace:FindPartOnRayWithIgnoreList(ray, ignoreList)
end
|
--[[
Returns true if the window is currently not breached
]] |
function Window:isNormal()
return self._state == Constants.State.Window.Normal
end
|
--[[Brakes]] |
Tune.ABSEnabled = true -- Implements ABS
Tune.ABSThreshold = 20 -- Slip speed allowed before ABS starts working (in SPS)
Tune.FBrakeForce = 1800 -- Front brake force
Tune.RBrakeForce = 1700 -- Rear brake force
Tune.PBrakeForce = 15000 -- Handbrake force
Tune.FLgcyBForce = 15000 -- Front brake force [PGS OFF]
Tune.RLgcyBForce = 10000 -- Rear brake force [PGS OFF]
Tune.LgcyPBForce = 25000 -- Handbrake force [PGS OFF]
|
-- DEPRECATED |
local module = {}
function module:init_instance_dynamically(ad)
local PublicAPI = require(script.Parent.PublicAPI)
PublicAPI.dynamicLoadBillboardAd(ad)
end
function module:init_3d_instance_dynamically(ad)
local PublicAPI = require(script.Parent.PublicAPI)
PublicAPI.dynamicLoadBoxAd(ad)
end
return module
|
-- Local Functions |
local function isInTutorial()
return TutorialPanels.Visible
end
local function makeShoeParticle()
local particle = ShoeParticle:Clone()
local randomX = (math.random() - .5)/10
particle.Position = UDim2.fromScale(.5 + randomX, .9)
particle.Parent = GameplayUi
TweenService:Create(particle, TweenInfo.new(.75), {
Position = UDim2.fromScale(particle.Position.X.Scale, .85),
Rotation = math.random(-50, 50),
Size = UDim2.fromScale(1, .065),
ImageTransparency = 1,
}, function()
particle:Destroy()
end):Play()
end
local function registerMovement()
cooldown = true
clickButton.Image = "rbxassetid://5301573887"
makeShoeParticle()
-- Have the player move to the next waypoint and tell the waypoint tracker to be
-- active in checking if they've reached the waypoint.
controller:TrackPlayer()
end
|
-- T A B C mode opcode |
opmode(0, 1, "OpArgK", "OpArgN", "iABx"), -- OP_LOADK
opmode(0, 1, "OpArgU", "OpArgU", "iABC"), -- OP_LOADBOOL
opmode(0, 1, "OpArgR", "OpArgN", "iABC"), -- OP_LOADNIL
opmode(0, 1, "OpArgU", "OpArgN", "iABC"), -- OP_GETUPVAL
opmode(0, 1, "OpArgK", "OpArgN", "iABx"), -- OP_GETGLOBAL
opmode(0, 1, "OpArgR", "OpArgK", "iABC"), -- OP_GETTABLE
opmode(0, 0, "OpArgK", "OpArgN", "iABx"), -- OP_SETGLOBAL
opmode(0, 0, "OpArgU", "OpArgN", "iABC"), -- OP_SETUPVAL
opmode(0, 0, "OpArgK", "OpArgK", "iABC"), -- OP_SETTABLE
opmode(0, 1, "OpArgU", "OpArgU", "iABC"), -- OP_NEWTABLE
opmode(0, 1, "OpArgR", "OpArgK", "iABC"), -- OP_SELF
opmode(0, 1, "OpArgK", "OpArgK", "iABC"), -- OP_ADD
opmode(0, 1, "OpArgK", "OpArgK", "iABC"), -- OP_SUB
opmode(0, 1, "OpArgK", "OpArgK", "iABC"), -- OP_MUL
opmode(0, 1, "OpArgK", "OpArgK", "iABC"), -- OP_DIV
opmode(0, 1, "OpArgK", "OpArgK", "iABC"), -- OP_MOD
opmode(0, 1, "OpArgK", "OpArgK", "iABC"), -- OP_POW
opmode(0, 1, "OpArgR", "OpArgN", "iABC"), -- OP_UNM
opmode(0, 1, "OpArgR", "OpArgN", "iABC"), -- OP_NOT
opmode(0, 1, "OpArgR", "OpArgN", "iABC"), -- OP_LEN
opmode(0, 1, "OpArgR", "OpArgR", "iABC"), -- OP_CONCAT
opmode(0, 0, "OpArgR", "OpArgN", "iAsBx"), -- OP_JMP
opmode(1, 0, "OpArgK", "OpArgK", "iABC"), -- OP_EQ
opmode(1, 0, "OpArgK", "OpArgK", "iABC"), -- OP_LT
opmode(1, 0, "OpArgK", "OpArgK", "iABC"), -- OP_LE
opmode(1, 1, "OpArgR", "OpArgU", "iABC"), -- OP_TEST
opmode(1, 1, "OpArgR", "OpArgU", "iABC"), -- OP_TESTSET
opmode(0, 1, "OpArgU", "OpArgU", "iABC"), -- OP_CALL
opmode(0, 1, "OpArgU", "OpArgU", "iABC"), -- OP_TAILCALL
opmode(0, 0, "OpArgU", "OpArgN", "iABC"), -- OP_RETURN
opmode(0, 1, "OpArgR", "OpArgN", "iAsBx"), -- OP_FORLOOP
opmode(0, 1, "OpArgR", "OpArgN", "iAsBx"), -- OP_FORPREP
opmode(1, 0, "OpArgN", "OpArgU", "iABC"), -- OP_TFORLOOP
opmode(0, 0, "OpArgU", "OpArgU", "iABC"), -- OP_SETLIST
opmode(0, 0, "OpArgN", "OpArgN", "iABC"), -- OP_CLOSE
opmode(0, 1, "OpArgU", "OpArgN", "iABx"), -- OP_CLOSURE
opmode(0, 1, "OpArgU", "OpArgN", "iABC"), -- OP_VARARG
} |
--////////////////////////////////////////////////////////////////////////////////////////////
--////////////////////////////////////////////////////////////// Code to do chat window fading
--//////////////////////////////////////////////////////////////////////////////////////////// |
function CheckIfPointIsInSquare(checkPos, topLeft, bottomRight)
return (topLeft.X <= checkPos.X and checkPos.X <= bottomRight.X and
topLeft.Y <= checkPos.Y and checkPos.Y <= bottomRight.Y)
end
local backgroundIsFaded = false
local textIsFaded = false
local lastTextFadeTime = 0
local lastBackgroundFadeTime = 0
local fadedChanged = Instance.new("BindableEvent")
local mouseStateChanged = Instance.new("BindableEvent")
local chatBarFocusChanged = Instance.new("BindableEvent")
function DoBackgroundFadeIn(setFadingTime)
lastBackgroundFadeTime = tick()
backgroundIsFaded = false
fadedChanged:Fire()
ChatWindow:FadeInBackground((setFadingTime or ChatSettings.ChatDefaultFadeDuration))
local currentChannelObject = ChatWindow:GetCurrentChannel()
if (currentChannelObject) then
local Scroller = MessageLogDisplay.Scroller
Scroller.ScrollingEnabled = true
Scroller.ScrollBarThickness = moduleMessageLogDisplay.ScrollBarThickness
end
end
function DoBackgroundFadeOut(setFadingTime)
lastBackgroundFadeTime = tick()
backgroundIsFaded = true
fadedChanged:Fire()
ChatWindow:FadeOutBackground((setFadingTime or ChatSettings.ChatDefaultFadeDuration))
local currentChannelObject = ChatWindow:GetCurrentChannel()
if (currentChannelObject) then
local Scroller = MessageLogDisplay.Scroller
Scroller.ScrollingEnabled = false
Scroller.ScrollBarThickness = 0
end
end
function DoTextFadeIn(setFadingTime)
lastTextFadeTime = tick()
textIsFaded = false
fadedChanged:Fire()
ChatWindow:FadeInText((setFadingTime or ChatSettings.ChatDefaultFadeDuration) * 0)
end
function DoTextFadeOut(setFadingTime)
lastTextFadeTime = tick()
textIsFaded = true
fadedChanged:Fire()
ChatWindow:FadeOutText((setFadingTime or ChatSettings.ChatDefaultFadeDuration))
end
function DoFadeInFromNewInformation()
DoTextFadeIn()
if ChatSettings.ChatShouldFadeInFromNewInformation then
DoBackgroundFadeIn()
end
end
function InstantFadeIn()
DoBackgroundFadeIn(0)
DoTextFadeIn(0)
end
function InstantFadeOut()
DoBackgroundFadeOut(0)
DoTextFadeOut(0)
end
local mouseIsInWindow = nil
function UpdateFadingForMouseState(mouseState)
mouseIsInWindow = mouseState
mouseStateChanged:Fire()
if (ChatBar:IsFocused()) then return end
if (mouseState) then
DoBackgroundFadeIn()
DoTextFadeIn()
else
DoBackgroundFadeIn()
end
end
spawn(function()
while true do
RunService.RenderStepped:wait()
while (mouseIsInWindow or ChatBar:IsFocused()) do
if (mouseIsInWindow) then
mouseStateChanged.Event:wait()
end
if (ChatBar:IsFocused()) then
chatBarFocusChanged.Event:wait()
end
end
if (not backgroundIsFaded) then
local timeDiff = tick() - lastBackgroundFadeTime
if (timeDiff > ChatSettings.ChatWindowBackgroundFadeOutTime) then
DoBackgroundFadeOut()
end
elseif (not textIsFaded) then
local timeDiff = tick() - lastTextFadeTime
if (timeDiff > ChatSettings.ChatWindowTextFadeOutTime) then
DoTextFadeOut()
end
else
fadedChanged.Event:wait()
end
end
end)
function getClassicChatEnabled()
if ChatSettings.ClassicChatEnabled ~= nil then
return ChatSettings.ClassicChatEnabled
end
return Players.ClassicChat
end
function getBubbleChatEnabled()
if ChatSettings.BubbleChatEnabled ~= nil then
return ChatSettings.BubbleChatEnabled
end
return Players.BubbleChat
end
function bubbleChatOnly()
return not getClassicChatEnabled() and getBubbleChatEnabled()
end
function UpdateMousePosition(mousePos)
if not (moduleApiTable.Visible and moduleApiTable.IsCoreGuiEnabled and (moduleApiTable.TopbarEnabled or ChatSettings.ChatOnWithTopBarOff)) then return end
if bubbleChatOnly() then
return
end
local windowPos = ChatWindow.GuiObject.AbsolutePosition
local windowSize = ChatWindow.GuiObject.AbsoluteSize
local newMouseState = CheckIfPointIsInSquare(mousePos, windowPos, windowPos + windowSize)
if (newMouseState ~= mouseIsInWindow) then
UpdateFadingForMouseState(newMouseState)
end
end
UserInputService.InputChanged:connect(function(inputObject, gameProcessedEvent)
if (inputObject.UserInputType == Enum.UserInputType.MouseMovement) then
local mousePos = Vector2.new(inputObject.Position.X, inputObject.Position.Y)
UpdateMousePosition(mousePos)
end
end)
UserInputService.TouchTap:connect(function(tapPos, gameProcessedEvent)
UpdateMousePosition(tapPos[1])
end)
UserInputService.TouchMoved:connect(function(inputObject, gameProcessedEvent)
local tapPos = Vector2.new(inputObject.Position.X, inputObject.Position.Y)
UpdateMousePosition(tapPos)
end)
UserInputService.Changed:connect(function(prop)
if prop == "MouseBehavior" then
if UserInputService.MouseBehavior == Enum.MouseBehavior.LockCenter then
local windowPos = ChatWindow.GuiObject.AbsolutePosition
local windowSize = ChatWindow.GuiObject.AbsoluteSize
local screenSize = GuiParent.AbsoluteSize
local centerScreenIsInWindow = CheckIfPointIsInSquare(screenSize/2, windowPos, windowPos + windowSize)
if centerScreenIsInWindow then
UserInputService.MouseBehavior = Enum.MouseBehavior.Default
end
end
end
end)
|
--put on startercharacterscripts
--made this from a tutorial
--i'll take this as not mine cause i dont know how to script and this was from a tutorial |
local humanoid = script.Parent:WaitForChild("Humanoid")
humanoid.BreakJointsOnDeath = false
humanoid.Died:Connect(function()
for index,joint in pairs(script.Parent:GetDescendants()) do
if joint:IsA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
local a1 = Instance.new("Attachment")
local a2 = Instance.new("Attachment")
a1.Parent = joint.Part0
a2.Parent = joint.Part1
socket.Parent = joint.Parent
socket.Attachment0 = a1
socket.Attachment1 = a2
a1.CFrame = joint.C0
a2.CFrame = joint.C1
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
joint:Destroy()
end
end
end)
|
--EDIT BELOW---------------------------------------------------------------------- |
settings.PianoSoundRange = 50
settings.KeyAesthetics = true
settings.SoundSource = Piano.Keys.KeyBox
settings.CameraCFrame = CFrame.new(
(Box.CFrame * CFrame.new(0, 0, 1)).p, -- +z is towards player
(Box.CFrame * CFrame.new(0, 0, 0)).p
)
settings.Length = 5 |
--[[
Similar to finally, except rejections are propagated through it.
]] |
function Promise.prototype:done(finallyHandler)
assert(
finallyHandler == nil or type(finallyHandler) == "function",
string.format(ERROR_NON_FUNCTION, "Promise:done")
)
return self:_finally(debug.traceback(nil, 2), finallyHandler, true)
end
Promise.prototype.Done = Promise.prototype.done
|
--[[**
Decodes a string from Base64.
@param [string] Input The input string to decode.
@returns [string] The newly decoded string.
**--]] |
function Base64:Decode(Input)
local Output = {}
local Length = 0
for Index = 1, #Input, 4 do
local C1, C2, C3, C4 = string.byte(Input, Index, Index + 3)
local I1 = Indexes[C1] - 1
local I2 = Indexes[C2] - 1
local I3 = (Indexes[C3] or 1) - 1
local I4 = (Indexes[C4] or 1) - 1
local A = bit32_lshift(I1, 2) + bit32_rshift(I2, 4)
local B = bit32_lshift(bit32_band(I2, 15), 4) + bit32_rshift(I3, 2)
local C = bit32_lshift(bit32_band(I3, 3), 6) + I4
Length = Length + 1
Output[Length] = A
if C3 ~= 61 then Length = Length + 1 Output[Length] = B end
if C4 ~= 61 then Length = Length + 1 Output[Length] = C end
end
local NewOutput = {}
local NewLength = 0
for Index = 1, Length, 4096 do
NewLength = NewLength + 1
NewOutput[NewLength] = string.char(table.unpack(Output, Index, math.min(Index + 4096 - 1, Length)))
end
return table.concat(NewOutput)
end
return Base64
|
----- MAGIC NUMBERS ABOUT THE TOOL -----
-- How much damage a bullet does |
local Damage = 50 |
--[[ By: Brutez, 2/28/2015, 1:34 AM, (UTC-08:00) Pacific Time (US & Canada) ]] | --
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 JaneTheKiller=AdvancedRespawnScript.Parent;
if AdvancedRespawnScript and JaneTheKiller and JaneTheKiller:FindFirstChild("Thumbnail")then
JaneTheKiller:FindFirstChild("Thumbnail"):Destroy();
end;
local GameDerbis=Game:GetService("Debris");
local JaneTheKillerHumanoid;
for _,Child in pairs(JaneTheKiller:GetChildren())do
if Child and Child.ClassName=="Humanoid"and Child.Health~=0 then
JaneTheKillerHumanoid=Child;
end;
end;
local Respawndant=JaneTheKiller:Clone();
if PlayerSpawning then --[[ LOOK AT LINE: 2. ]]--
coroutine.resume(coroutine.create(function()
if JaneTheKiller and JaneTheKillerHumanoid and JaneTheKillerHumanoid:FindFirstChild("Status")and not JaneTheKillerHumanoid:FindFirstChild("Status"):FindFirstChild("AvalibleSpawns")then
SpawnModel=Instance.new("Model");
SpawnModel.Parent=JaneTheKillerHumanoid.Status;
SpawnModel.Name="AvalibleSpawns";
else
SpawnModel=JaneTheKillerHumanoid: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=JaneTheKiller;
RespawningForceField.Name="SpawnForceField";
GameDerbis:AddItem(RespawningForceField,SpawnItself.Name);
JaneTheKiller:MoveTo(SpawnItself.Value+Vector3.new(0,3.5,0));
else
if JaneTheKiller:FindFirstChild("SpawnForceField")then
JaneTheKiller:FindFirstChild("SpawnForceField"):Destroy();
end;
JaneTheKiller:MoveTo(Vector3.new(0,115,0));
end;
end));
end;
function Respawn()
Wait(5);
Respawndant.Parent=JaneTheKiller.Parent;
Respawndant:makeJoints();
Respawndant:FindFirstChild("Head"):MakeJoints();
Respawndant:FindFirstChild("Torso"):MakeJoints();
JaneTheKiller:remove();
end;
if AdvancedRespawnScript and JaneTheKiller and JaneTheKillerHumanoid then
JaneTheKillerHumanoid.Died:connect(Respawn);
end; |
-- Create component |
local ColorPicker = Roact.PureComponent:extend(script.Name)
function ColorPicker:init()
self.Maid = Maid.new()
local InitialHue,
InitialSaturation,
InitialBrightness = (self.props.InitialColor or Color3.fromHSV(0, 0.5, 1)):ToHSV()
self.HSV, self._SetHSV = Roact.createBinding({
H = InitialHue;
S = InitialSaturation;
V = InitialBrightness;
})
end
function ColorPicker:didUpdate(previousProps)
if previousProps.InitialColor ~= self.props.InitialColor then
local InitialHue,
InitialSaturation,
InitialBrightness = (self.props.InitialColor or Color3.fromHSV(0, 0.5, 1)):ToHSV()
self._SetHSV({
H = InitialHue;
S = InitialSaturation;
V = InitialBrightness;
})
end
end
function ColorPicker:SetHSV(HSV)
self._SetHSV(HSV)
if self.props.SetPreviewColor then
fastSpawn(function ()
self.props.SetPreviewColor(Color3.fromHSV(HSV.H, HSV.S, HSV.V))
end)
end
end
function ColorPicker:Finish()
if self.props.SetPreviewColor then
fastSpawn(function ()
self.props.SetPreviewColor(nil)
end)
end
if self.props.OnConfirm then
local HSV = self.HSV:getValue()
local Color = Color3.fromHSV(HSV.H, HSV.S, HSV.V)
fastSpawn(function ()
self.props.OnConfirm(Color)
end)
end
end
function ColorPicker:Cancel()
if self.props.SetPreviewColor then
fastSpawn(function ()
self.props.SetPreviewColor(nil)
end)
end
if self.props.OnCancel then
fastSpawn(function ()
self.props.OnCancel()
end)
end
end
function ColorPicker:render()
return new('ScreenGui', {
DisplayOrder = 1;
}, {
Dialog = new('Frame', {
Active = true;
Draggable = true;
ZIndex = 0;
AnchorPoint = Vector2.new(1, 0.5);
Position = self.DefaultPosition or UDim2.new(1, -110, 0.5, 0);
BackgroundTransparency = 1;
Size = UDim2.fromOffset(240, 0);
[Roact.Change.Position] = function (rbx)
ColorPicker.DefaultPosition = rbx.Position
end;
}, {
Layout = new('UIListLayout', {
FillDirection = Enum.FillDirection.Vertical;
SortOrder = Enum.SortOrder.LayoutOrder;
[Roact.Change.AbsoluteContentSize] = function (rbx)
rbx.Parent.Size = UDim2.fromOffset(240, rbx.AbsoluteContentSize.Y)
end;
});
Picker = new('Frame', {
BackgroundTransparency = 1;
BorderSizePixel = 0;
Size = UDim2.new(1, 0, 0, 0);
LayoutOrder = 0;
}, {
Layout = new('UIListLayout', {
Padding = UDim.new(0, 10);
FillDirection = Enum.FillDirection.Horizontal;
SortOrder = Enum.SortOrder.LayoutOrder;
[Roact.Change.AbsoluteContentSize] = function (rbx)
rbx.Parent.Size = UDim2.new(1, 0, 0, rbx.AbsoluteContentSize.Y)
end;
});
Color = new('Frame', {
BorderSizePixel = 0;
Size = UDim2.new(0.25, 0, 1, 0);
BackgroundColor3 = self.HSV:map(function (HSV)
return Color3.fromHSV(HSV.H, HSV.S, HSV.V)
end);
}, {
Corners = new('UICorner', {
CornerRadius = UDim.new(0, 4);
});
AspectRatio = new('UIAspectRatioConstraint', {
AspectRatio = 1;
});
});
Sliders = new('Frame', {
Position = UDim2.new(0.25, 5, 0, 0);
Size = UDim2.new(0.75, 0, 0, 0);
BackgroundTransparency = 1;
}, {
Layout = new('UIListLayout', {
Padding = UDim.new(0, 10);
FillDirection = Enum.FillDirection.Vertical;
HorizontalAlignment = Enum.HorizontalAlignment.Left;
VerticalAlignment = Enum.VerticalAlignment.Top;
SortOrder = Enum.SortOrder.LayoutOrder;
[Roact.Change.AbsoluteContentSize] = function (rbx)
rbx.Parent.Size = UDim2.new(0.75, 0, 0, rbx.AbsoluteContentSize.Y)
end;
});
HueSlider = new(Slider, {
Size = UDim2.new(1, 0, 0, 10);
BackgroundColor3 = Color3.fromRGB(255, 255, 255);
LayoutOrder = 0;
Value = self.HSV:map(function (HSV)
return HSV.H
end);
OnValueChanged = function (Value)
local HSV = self.HSV:getValue()
self:SetHSV({
H = Value;
S = HSV.S;
V = HSV.V;
})
end;
}, {
Gradient = new('UIGradient', {
Color = self.HSV:map(function (HSV)
return ColorSequence.new({
ColorSequenceKeypoint.new(0/6, Color3.fromHSV(0/6, HSV.S, HSV.V));
ColorSequenceKeypoint.new(1/6, Color3.fromHSV(1/6, HSV.S, HSV.V));
ColorSequenceKeypoint.new(2/6, Color3.fromHSV(2/6, HSV.S, HSV.V));
ColorSequenceKeypoint.new(3/6, Color3.fromHSV(3/6, HSV.S, HSV.V));
ColorSequenceKeypoint.new(4/6, Color3.fromHSV(4/6, HSV.S, HSV.V));
ColorSequenceKeypoint.new(5/6, Color3.fromHSV(5/6, HSV.S, HSV.V));
ColorSequenceKeypoint.new(6/6, Color3.fromHSV(6/6, HSV.S, HSV.V));
})
end);
});
});
SaturationSlider = new(Slider, {
Size = UDim2.new(1, 0, 0, 10);
BackgroundColor3 = Color3.fromRGB(255, 255, 255);
LayoutOrder = 1;
Value = self.HSV:map(function (HSV)
return HSV.S
end);
OnValueChanged = function (Value)
local HSV = self.HSV:getValue()
self:SetHSV({
H = HSV.H;
S = Value;
V = HSV.V;
})
end;
}, {
Gradient = new('UIGradient', {
Color = self.HSV:map(function (HSV)
return ColorSequence.new(
Color3.fromHSV(HSV.H, 0, HSV.V),
Color3.fromHSV(HSV.H, 1, HSV.V)
)
end);
});
});
BrightnessSlider = new(Slider, {
Size = UDim2.new(1, 0, 0, 10);
BackgroundColor3 = Color3.fromRGB(255, 255, 255);
LayoutOrder = 2;
Value = self.HSV:map(function (HSV)
return HSV.V
end);
OnValueChanged = function (Value)
local HSV = self.HSV:getValue()
self:SetHSV({
H = HSV.H;
S = HSV.S;
V = Value;
})
end;
}, {
Gradient = new('UIGradient', {
Color = self.HSV:map(function (HSV)
return ColorSequence.new(
Color3.fromHSV(HSV.H, HSV.S, 0),
Color3.fromHSV(HSV.H, HSV.S, 1)
)
end);
});
});
});
});
Bottom = new('Frame', {
BackgroundTransparency = 1;
BorderSizePixel = 0;
Size = UDim2.new(1, 0, 0, 34);
LayoutOrder = 1;
}, {
HSVLabel = new('TextLabel', {
BackgroundTransparency = 1;
Position = UDim2.new(0, 0, 0, 7);
Font = Enum.Font.GothamBlack;
Text = 'HSV: ';
TextSize = 11;
TextColor3 = Color3.fromRGB(255, 255, 255);
TextStrokeTransparency = 0.95;
[Roact.Change.TextBounds] = function (rbx)
rbx.Size = UDim2.fromOffset(rbx.TextBounds.X, rbx.TextBounds.Y)
end;
}, {
HSVInput = new('TextBox', {
BackgroundTransparency = 1;
Position = UDim2.new(1, 0, 0, 0);
ClearTextOnFocus = false;
Font = Enum.Font.Gotham;
Text = self.HSV:map(function (HSV)
local Hue = tostring(math.floor(HSV.H * 360)) .. '°'
local Saturation = tostring(math.floor(HSV.S * 100)) .. '%'
local Brightness = tostring(math.floor(HSV.V * 100)) .. '%'
return Hue .. ', ' .. Saturation .. ', ' .. Brightness
end);
TextSize = 11;
TextColor3 = Color3.fromRGB(255, 255, 255);
TextStrokeTransparency = 0.95;
TextXAlignment = Enum.TextXAlignment.Left;
[Roact.Change.TextBounds] = function (rbx)
rbx.Size = UDim2.fromOffset(rbx.TextBounds.X, rbx.TextBounds.Y)
end;
[Roact.Event.FocusLost] = function (rbx)
local HueInput, SaturationInput, BrightnessInput = rbx.Text:match('([0-9]+)[^0-9]+([0-9]+)[^0-9]+([0-9]+)')
if HueInput and SaturationInput and BrightnessInput then
self:SetHSV({
H = math.clamp(tonumber(HueInput) / 360, 0, 1);
S = math.clamp(tonumber(SaturationInput) / 100, 0, 1);
V = math.clamp(tonumber(BrightnessInput) / 100, 0, 1);
})
end
end;
});
});
RGBLabel = new('TextLabel', {
BackgroundTransparency = 1;
Position = UDim2.new(0, 0, 0, 7 + 11 + 4);
Font = Enum.Font.GothamBlack;
Text = 'RGB: ';
TextSize = 11;
TextColor3 = Color3.fromRGB(255, 255, 255);
TextStrokeTransparency = 0.95;
[Roact.Change.TextBounds] = function (rbx)
rbx.Size = UDim2.fromOffset(rbx.TextBounds.X, rbx.TextBounds.Y)
end;
}, {
RGBInput = new('TextBox', {
BackgroundTransparency = 1;
Position = UDim2.new(1, 0, 0, 0);
ClearTextOnFocus = false;
Font = Enum.Font.Gotham;
Text = self.HSV:map(function (HSV)
local Color = Color3.fromHSV(HSV.H, HSV.S, HSV.V)
local R = tostring(math.round(Color.R * 255))
local G = tostring(math.round(Color.G * 255))
local B = tostring(math.round(Color.B * 255))
return R .. ', ' .. G .. ', ' .. B
end);
TextSize = 11;
TextColor3 = Color3.fromRGB(255, 255, 255);
TextStrokeTransparency = 0.95;
TextXAlignment = Enum.TextXAlignment.Left;
[Roact.Change.TextBounds] = function (rbx)
rbx.Size = UDim2.fromOffset(rbx.TextBounds.X, rbx.TextBounds.Y)
end;
[Roact.Event.FocusLost] = function (rbx)
local RInput, GInput, BInput = rbx.Text:match('([0-9]+)[^0-9]+([0-9]+)[^0-9]+([0-9]+)')
if RInput and GInput and BInput then
local Color = Color3.fromRGB(
math.clamp(tonumber(RInput), 0, 255),
math.clamp(tonumber(GInput), 0, 255),
math.clamp(tonumber(BInput), 0, 255)
)
local H, S, V = Color:ToHSV()
self:SetHSV({
H = H;
S = S;
V = V;
})
end
end;
});
});
ConfirmButton = new('ImageButton', {
BackgroundTransparency = 1;
Size = UDim2.new(0, 23, 0, 23);
Position = UDim2.new(1, 0, 1, 0);
AnchorPoint = Vector2.new(1, 1);
Image = 'rbxassetid://2132729935';
ScaleType = Enum.ScaleType.Slice;
SliceCenter = Rect.new(8, 8, 34, 34);
SliceScale = 0.5;
[Roact.Event.Activated] = function (rbx)
self:Finish()
end;
}, {
Label = new('TextLabel', {
BackgroundTransparency = 1;
Size = UDim2.new(1, 0, 1, 0);
Text = '✔';
Font = Enum.Font.GothamSemibold;
TextSize = 12;
TextColor3 = Color3.fromRGB(0, 0, 0);
});
});
CancelButton = new('ImageButton', {
BackgroundTransparency = 1;
Size = UDim2.new(0, 25, 0, 23);
Position = UDim2.new(1, -30, 1, 0);
AnchorPoint = Vector2.new(1, 1);
Image = 'rbxassetid://2218340938';
ScaleType = Enum.ScaleType.Slice;
SliceCenter = Rect.new(8, 8, 34, 34);
SliceScale = 0.5;
[Roact.Event.Activated] = function (rbx)
self:Cancel()
end;
}, {
Label = new('TextLabel', {
BackgroundTransparency = 1;
Size = UDim2.new(1, 0, 1, 0);
Text = 'Cancel';
Font = Enum.Font.GothamSemibold;
TextColor3 = Color3.fromRGB(255, 255, 255);
TextSize = 12;
TextStrokeTransparency = 0.95;
[Roact.Change.TextBounds] = function (rbx)
rbx.Parent.Size = UDim2.new(0, rbx.TextBounds.X + 10, 0, 23);
end;
});
});
});
})
})
end
return ColorPicker
|
-- Set up the Local Player |
if RunService:IsClient() then
if LocalPlayer.Character then
onCharacterAdded(LocalPlayer.Character)
end
LocalPlayer.CharacterAdded:Connect(onCharacterAdded)
LocalPlayer.CharacterRemoving:Connect(onCharacterRemoving)
end
local ShoulderCamera = {}
ShoulderCamera.__index = ShoulderCamera
ShoulderCamera.SpringService = nil
function ShoulderCamera.new(weaponsSystem)
local self = setmetatable({}, ShoulderCamera)
self.weaponsSystem = weaponsSystem
-- Configuration parameters (constants)
self.fieldOfView = 70
self.minPitch = math.rad(-75) -- min degrees camera can angle down
self.maxPitch = math.rad(75) -- max degrees camera can cangle up
self.normalOffset = Vector3.new(2.25, 2.25, 10.5) -- this is the camera's offset from the player
self.zoomedOffsetDistance = 8 -- number of studs to zoom in from default offset when zooming
self.normalCrosshairScale = 1
self.zoomedCrosshairScale = 0.75
self.defaultZoomFactor = 1
self.canZoom = true
self.zoomInputs = { Enum.UserInputType.MouseButton2, Enum.KeyCode.ButtonL2 }
self.sprintInputs = { Enum.KeyCode.LeftShift }
self.mouseRadsPerPixel = Vector2.new(1 / 480, 1 / 480)
self.zoomedMouseRadsPerPixel = Vector2.new(1 / 1200, 1 / 1200)
self.touchSensitivity = Vector2.new(1 / 100, 1 / 100)
self.zoomedTouchSensitivity = Vector2.new(1 / 200, 1 / 200)
self.touchDelayTime = 0.25 -- max time for a touch to count as a tap (to shoot the weapon instead of control camera),
-- also the amount of time players have to start a second touch after releasing the first time to trigger automatic fire
self.recoilDecay = 2 -- higher number means faster recoil decay rate
self.rotateCharacterWithCamera = true
self.gamepadSensitivityModifier = Vector2.new(0.85, 0.65)
-- Walk speeds
self.zoomWalkSpeed = 8
self.normalWalkSpeed = 16
self.sprintingWalkSpeed = 24
-- Current state
self.enabled = false
self.yaw = 0
self.pitch = 0
self.currentCFrame = CFrame.new()
self.currentOffset = self.normalOffset
self.currentRecoil = Vector2.new(0, 0)
self.currentMouseRadsPerPixel = self.mouseRadsPerPixel
self.currentTouchSensitivity = self.touchSensitivity
self.mouseLocked = true
self.touchPanAccumulator = Vector2.new(0, 0) -- used for touch devices, represents amount the player has dragged their finger since starting a touch
self.currentTool = nil
self.sprintingInputActivated = false
self.desiredWalkSpeed = self.normalWalkSpeed
self.sprintEnabled = false -- true means player will move faster while doing sprint inputs
self.slowZoomWalkEnabled = false -- true means player will move slower while doing zoom inputs
self.desiredFieldOfView = self.fieldOfView
-- Zoom variables
self.zoomedFromInput = false -- true if player has performed input to zoom
self.forcedZoomed = false -- ignores zoomedFromInput and canZoom
self.zoomState = false -- true if player is currently zoomed in
self.zoomAlpha = 0
self.hasScope = false
self.hideToolWhileZoomed = false
self.currentZoomFactor = self.defaultZoomFactor
self.zoomedFOV = self.fieldOfView
-- Gamepad variables
self.gamepadPan = Vector2.new(0, 0) -- essentially the amount the gamepad has moved from resting position
self.movementPan = Vector2.new(0, 0) -- this is for movement (gamepadPan is for camera)
self.lastThumbstickPos = Vector2.new(0, 0)
self.lastThumbstickTime = nil
self.currentGamepadSpeed = 0
self.lastGamepadVelocity = Vector2.new(0, 0)
-- Occlusion
self.lastOcclusionDistance = 0
self.lastOcclusionReachedTime = 0 -- marks the last time camera was at the true occlusion distance
self.defaultTimeUntilZoomOut = 0
self.timeUntilZoomOut = self.defaultTimeUntilZoomOut -- time after lastOcclusionReachedTime that camera will zoom out
self.timeLastPoppedWayIn = 0 -- this holds the last time camera popped nearly into first person
self.isZoomingOut = false
self.tweenOutTime = 0.2
self.curOcclusionTween = nil
self.occlusionTweenObject = nil
-- Side correction (when player is against a wall)
self.sideCorrectionGoalVector = nil
self.lastSideCorrectionMagnitude = 0
self.lastSideCorrectionReachedTime = 0 -- marks the last time the camera was at the true correction distance
self.revertSideCorrectionSpeedMultiplier = 2 -- speed at which camera reverts the side correction (towards 0 correction)
self.defaultTimeUntilRevertSideCorrection = 0.75
self.timeUntilRevertSideCorrection = self.defaultTimeUntilRevertSideCorrection -- time after lastSideCorrectionReachedTime that camera will revert the correction
self.isRevertingSideCorrection = false
-- Datamodel references
self.eventConnections = {}
self.raycastIgnoreList = {}
self.currentCamera = nil
self.currentCharacter = nil
self.currentHumanoid = nil
self.currentRootPart = nil
self.controlModule = nil -- used to get player's touch input for moving character
self.random = Random.new()
return self
end
function ShoulderCamera:setEnabled(enabled)
if self.enabled == enabled then
return
end
self.enabled = enabled
if self.enabled then
RunService:BindToRenderStep(CAMERA_RENDERSTEP_NAME, Enum.RenderPriority.Camera.Value - 1, function(dt) self:onRenderStep(dt) end)
ContextActionService:BindAction(ZOOM_ACTION_NAME, function(...) self:onZoomAction(...) end, false, unpack(self.zoomInputs))
ContextActionService:BindAction(SPRINT_ACTION_NAME, function(...) self:onSprintAction(...) end, false, unpack(self.sprintInputs))
table.insert(self.eventConnections, LocalPlayer.CharacterAdded:Connect(function(character) self:onCurrentCharacterChanged(character) end))
table.insert(self.eventConnections, LocalPlayer.CharacterRemoving:Connect(function() self:onCurrentCharacterChanged(nil) end))
table.insert(self.eventConnections, workspace:GetPropertyChangedSignal("CurrentCamera"):Connect(function() self:onCurrentCameraChanged(workspace.CurrentCamera) end))
table.insert(self.eventConnections, UserInputService.InputBegan:Connect(function(inputObj, wasProcessed) self:onInputBegan(inputObj, wasProcessed) end))
table.insert(self.eventConnections, UserInputService.InputChanged:Connect(function(inputObj, wasProcessed) self:onInputChanged(inputObj, wasProcessed) end))
table.insert(self.eventConnections, UserInputService.InputEnded:Connect(function(inputObj, wasProcessed) self:onInputEnded(inputObj, wasProcessed) end))
self:onCurrentCharacterChanged(LocalPlayer.Character)
self:onCurrentCameraChanged(workspace.CurrentCamera)
-- Make transition to shouldercamera smooth by facing in same direction as previous camera
local cameraLook = self.currentCamera.CFrame.lookVector
self.yaw = math.atan2(-cameraLook.X, -cameraLook.Z)
self.pitch = math.asin(cameraLook.Y)
self.currentCamera.CameraType = Enum.CameraType.Scriptable
self:setZoomFactor(self.currentZoomFactor) -- this ensures that zoomedFOV reflecs currentZoomFactor
workspace.CurrentCamera.CameraSubject = self.currentRootPart
self.occlusionTweenObject = Instance.new("NumberValue")
self.occlusionTweenObject.Name = "OcclusionTweenObject"
self.occlusionTweenObject.Parent = script
self.occlusionTweenObject.Changed:Connect(function(value)
self.lastOcclusionDistance = value
end)
-- Sets up weapon system to use camera for raycast direction instead of gun look vector
self.weaponsSystem.aimRayCallback = function()
local cameraCFrame = self.currentCFrame
return Ray.new(cameraCFrame.p, cameraCFrame.LookVector * 500)
end
else
RunService:UnbindFromRenderStep(CAMERA_RENDERSTEP_NAME)
ContextActionService:UnbindAction(ZOOM_ACTION_NAME)
ContextActionService:UnbindAction(SPRINT_ACTION_NAME)
if self.currentHumanoid then
self.currentHumanoid.AutoRotate = true
end
if self.currentCamera then
self.currentCamera.CameraSubject = self.currentHumanoid
self.currentCamera.CameraType = Enum.CameraType.Custom
end
self:updateZoomState()
self.yaw = 0
self.pitch = 0
for _, conn in pairs(self.eventConnections) do
conn:Disconnect()
end
self.eventConnections = {}
UserInputService.MouseBehavior = Enum.MouseBehavior.Default
UserInputService.MouseIconEnabled = true
end
end
function ShoulderCamera:onRenderStep(dt)
if not self.enabled or
not self.currentCamera or
not self.currentCharacter or
not self.currentHumanoid or
not self.currentRootPart
then
return
end
-- Hide mouse and lock to center if applicable
if self.mouseLocked and not GuiService:GetEmotesMenuOpen() then
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
UserInputService.MouseIconEnabled = false
else
UserInputService.MouseBehavior = Enum.MouseBehavior.Default
UserInputService.MouseIconEnabled = true
end
-- Handle gamepad input
self:processGamepadInput(dt)
-- Smoothly zoom to desired values
if self.hasScope then
ShoulderCamera.SpringService:Target(self, 0.8, 8, { zoomAlpha = self.zoomState and 1 or 0 })
ShoulderCamera.SpringService:Target(self.currentCamera, 0.8, 8, { FieldOfView = self.desiredFieldOfView })
else
ShoulderCamera.SpringService:Target(self, 0.8, 3, { zoomAlpha = self.zoomState and 1 or 0 })
ShoulderCamera.SpringService:Target(self.currentCamera, 0.8, 3, { FieldOfView = self.desiredFieldOfView })
end
-- Handle walk speed changes
if self.sprintEnabled or self.slowZoomWalkEnabled then
self.desiredWalkSpeed = self.normalWalkSpeed
if self.sprintEnabled and (self.sprintingInputActivated or self:sprintFromTouchInput() or self:sprintFromGamepadInput()) and not self.zoomState then
self.desiredWalkSpeed = self.sprintingWalkSpeed
end
if self.slowZoomWalkEnabled and self.zoomAlpha > 0.1 then
self.desiredWalkSpeed = self.zoomWalkSpeed
end
ShoulderCamera.SpringService:Target(self.currentHumanoid, 0.95, 4, { WalkSpeed = self.desiredWalkSpeed })
end
-- Initialize variables used for side correction, occlusion, and calculating camera focus/rotation
local rootPartPos = self.currentRootPart.CFrame.Position
local rootPartUnrotatedCFrame = CFrame.new(rootPartPos)
local yawRotation = CFrame.Angles(0, self.yaw, 0)
local pitchRotation = CFrame.Angles(self.pitch + self.currentRecoil.Y, 0, 0)
local xOffset = CFrame.new(self.normalOffset.X, 0, 0)
local yOffset = CFrame.new(0, self.normalOffset.Y, 0)
local zOffset = CFrame.new(0, 0, self.normalOffset.Z)
local collisionRadius = self:getCollisionRadius()
local cameraYawRotationAndXOffset =
yawRotation * -- First rotate around the Y axis (look left/right)
xOffset -- Then perform the desired offset (so camera is centered to side of player instead of directly on player)
local cameraFocus = rootPartUnrotatedCFrame * cameraYawRotationAndXOffset
-- Handle/Calculate side correction when player is adjacent to a wall (so camera doesn't go in the wall)
local vecToFocus = cameraFocus.p - rootPartPos
local rayToFocus = Ray.new(rootPartPos, vecToFocus + (vecToFocus.Unit * collisionRadius))
local hitPart, hitPoint, hitNormal = self:penetrateCast(rayToFocus, self.raycastIgnoreList)
local currentTime = tick()
local sideCorrectionGoalVector = Vector3.new() -- if nothing is adjacent to player, goal vector is (0, 0, 0)
if hitPart then
hitPoint = hitPoint + (hitNormal * collisionRadius)
sideCorrectionGoalVector = hitPoint - cameraFocus.p
if sideCorrectionGoalVector.Magnitude >= self.lastSideCorrectionMagnitude then -- make it easy for camera to pop closer to player (move left)
if currentTime > self.lastSideCorrectionReachedTime + self.timeUntilRevertSideCorrection and self.lastSideCorrectionMagnitude ~= 0 then
self.timeUntilRevertSideCorrection = self.defaultTimeUntilRevertSideCorrection * 2 -- double time until revert if popping in repeatedly
elseif self.lastSideCorrectionMagnitude == 0 and self.timeUntilRevertSideCorrection ~= self.defaultTimeUntilRevertSideCorrection then
self.timeUntilRevertSideCorrection = self.defaultTimeUntilRevertSideCorrection
end
self.lastSideCorrectionMagnitude = sideCorrectionGoalVector.Magnitude
self.lastSideCorrectionReachedTime = currentTime
self.isRevertingSideCorrection = false
else
self.isRevertingSideCorrection = true
end
elseif self.lastSideCorrectionMagnitude ~= 0 then
self.isRevertingSideCorrection = true
end
if self.isRevertingSideCorrection then -- make it hard/slow for camera to revert side correction (move right)
if sideCorrectionGoalVector.Magnitude > self.lastSideCorrectionMagnitude - 1 and sideCorrectionGoalVector.Magnitude ~= 0 then
self.lastSideCorrectionReachedTime = currentTime -- reset timer if occlusion significantly increased since last frame
end
if currentTime > self.lastSideCorrectionReachedTime + self.timeUntilRevertSideCorrection then
local sideCorrectionChangeAmount = dt * (vecToFocus.Magnitude) * self.revertSideCorrectionSpeedMultiplier
self.lastSideCorrectionMagnitude = self.lastSideCorrectionMagnitude - sideCorrectionChangeAmount
if sideCorrectionGoalVector.Magnitude >= self.lastSideCorrectionMagnitude then
self.lastSideCorrectionMagnitude = sideCorrectionGoalVector.Magnitude
self.lastSideCorrectionReachedTime = currentTime
self.isRevertingSideCorrection = false
end
end
end
-- Update cameraFocus to reflect side correction
cameraYawRotationAndXOffset = cameraYawRotationAndXOffset + (-vecToFocus.Unit * self.lastSideCorrectionMagnitude)
cameraFocus = rootPartUnrotatedCFrame * cameraYawRotationAndXOffset
self.currentCamera.Focus = cameraFocus
-- Calculate and apply CFrame for camera
local cameraCFrameInSubjectSpace =
cameraYawRotationAndXOffset *
pitchRotation * -- rotate around the X axis (look up/down)
yOffset * -- move camera up/vertically
zOffset -- move camera back
self.currentCFrame = rootPartUnrotatedCFrame * cameraCFrameInSubjectSpace
-- Move camera forward if zoomed in
if self.zoomAlpha > 0 then
local trueZoomedOffset = math.max(self.zoomedOffsetDistance - self.lastOcclusionDistance, 0) -- don't zoom too far in if already occluded
self.currentCFrame = self.currentCFrame:lerp(self.currentCFrame + trueZoomedOffset * self.currentCFrame.LookVector.Unit, self.zoomAlpha)
end
self.currentCamera.CFrame = self.currentCFrame
-- Handle occlusion
local occlusionDistance = self.currentCamera:GetLargestCutoffDistance(self.raycastIgnoreList)
if occlusionDistance > 1e-5 then
occlusionDistance = occlusionDistance + collisionRadius
end
if occlusionDistance >= self.lastOcclusionDistance then -- make it easy for the camera to pop in towards the player
if self.curOcclusionTween ~= nil then
self.curOcclusionTween:Cancel()
self.curOcclusionTween = nil
end
if currentTime > self.lastOcclusionReachedTime + self.timeUntilZoomOut and self.lastOcclusionDistance ~= 0 then
self.timeUntilZoomOut = self.defaultTimeUntilZoomOut * 2 -- double time until zoom out if popping in repeatedly
elseif self.lastOcclusionDistance == 0 and self.timeUntilZoomOut ~= self.defaultTimeUntilZoomOut then
self.timeUntilZoomOut = self.defaultTimeUntilZoomOut
end
if occlusionDistance / self.normalOffset.Z > 0.8 and self.timeLastPoppedWayIn == 0 then
self.timeLastPoppedWayIn = currentTime
end
self.lastOcclusionDistance = occlusionDistance
self.lastOcclusionReachedTime = currentTime
self.isZoomingOut = false
else -- make it hard/slow for camera to zoom out
self.isZoomingOut = true
if occlusionDistance > self.lastOcclusionDistance - 2 and occlusionDistance ~= 0 then -- reset timer if occlusion significantly increased since last frame
self.lastOcclusionReachedTime = currentTime
end
-- If occlusion pops camera in to almost first person for a short time, pop out instantly
if currentTime < self.timeLastPoppedWayIn + self.defaultTimeUntilZoomOut and self.lastOcclusionDistance / self.normalOffset.Z > 0.8 then
self.lastOcclusionDistance = occlusionDistance
self.lastOcclusionReachedTime = currentTime
self.isZoomingOut = false
elseif currentTime >= self.timeLastPoppedWayIn + self.defaultTimeUntilZoomOut and self.timeLastPoppedWayIn ~= 0 then
self.timeLastPoppedWayIn = 0
end
end
-- Update occlusion amount if timeout time has passed
if currentTime >= self.lastOcclusionReachedTime + self.timeUntilZoomOut and not self.zoomState then
if self.curOcclusionTween == nil then
self.occlusionTweenObject.Value = self.lastOcclusionDistance
local tweenInfo = TweenInfo.new(self.tweenOutTime)
local goal = {}
goal.Value = self.lastOcclusionDistance - self.normalOffset.Z
self.curOcclusionTween = TweenService:Create(self.occlusionTweenObject, tweenInfo, goal)
self.curOcclusionTween:Play()
end
end
-- Apply occlusion to camera CFrame
local currentOffsetDir = self.currentCFrame.LookVector.Unit
self.currentCFrame = self.currentCFrame + (currentOffsetDir * self.lastOcclusionDistance)
self.currentCamera.CFrame = self.currentCFrame
-- Apply recoil decay
self.currentRecoil = self.currentRecoil - (self.currentRecoil * self.recoilDecay * dt)
if self:isHumanoidControllable() and self.rotateCharacterWithCamera then
self.currentHumanoid.AutoRotate = false
self.currentRootPart.CFrame = CFrame.Angles(0, self.yaw, 0) + self.currentRootPart.Position -- rotate character to be upright and facing the same direction as camera
self:applyRootJointFix()
else
self.currentHumanoid.AutoRotate = true
end
self:handlePartTransparencies()
self:handleTouchToolFiring()
end
|
--Made by Luckymaxer |
Tool = script.Parent
Handle = Tool:WaitForChild("Handle")
Fire = Handle:WaitForChild("Fire")
Players = game:GetService("Players")
Debris = game:GetService("Debris")
RunService = game:GetService("RunService")
RbxUtility = LoadLibrary("RbxUtility")
Create = RbxUtility.Create
DeathEffect = script:WaitForChild("DeathEffect")
DamageValues = {
BaseDamage = 44,
SlashDamage = 50,
LungeDamage = 56,
}
Damage = DamageValues.BaseDamage
BaseUrl = "http://www.roblox.com/asset/?id="
BasePart = Instance.new("Part")
BasePart.Shape = Enum.PartType.Block
BasePart.Material = Enum.Material.Plastic
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 = true
BasePart.Locked = true
BasePart.Anchored = false
Special = {
Active = false,
Enabled = true,
Duration = 15,
CoolDown = 10,
}
Animations = {
Equip = {Animation = Tool:WaitForChild("Equip"), FadeTime = nil, Weight = nil, Speed = 0.7, Duration = 1},
LeftSlash = {Animation = Tool:WaitForChild("LeftSlash"), FadeTime = nil, Weight = nil, Speed = 1.5, Duration = 0.75},
RightSlash = {Animation = Tool:WaitForChild("RightSlash"), FadeTime = nil, Weight = nil, Speed = 1.5, Duration = 0.75},
SideSwipe = {Animation = Tool:WaitForChild("SideSwipe"), FadeTime = nil, Weight = nil, Speed = 0.8, Duration = 0.75},
Explode = {Animation = Tool:WaitForChild("Explode"), FadeTime = 0.25, Weight = nil, Speed = 2, Duration = 0.75},
}
Sounds = {
Unsheath = Handle:WaitForChild("Unsheath"),
Slash = Handle:WaitForChild("Slash"),
Lunge = Handle:WaitForChild("Lunge"),
}
Grips = {
Up = CFrame.new(0, -1.85, 0.05, 1, 0, -0, 0, 1, 0, 0, 0, 1),
Out = CFrame.new(0, -1.85, 0.05, 1, 0, 0, 0, 0, -1, -0, 1, 0),
}
LastAttack = 0
ToolEquipped = false
ServerControl = (Tool:FindFirstChild("ServerControl") or Create("RemoteFunction"){
Name = "ServerControl",
Parent = Tool,
})
ClientControl = (Tool:FindFirstChild("ClientControl") or Create("RemoteFunction"){
Name = "ClientControl",
Parent = Tool,
})
Handle.Transparency = 0
Fire.Enabled = false
Tool.Grip = Grips.Up
Tool.Enabled = true
function IsTeamMate(Player1, Player2)
return (Player1 and Player2 and not Player1.Neutral and not Player2.Neutral and Player1.TeamColor == Player2.TeamColor)
end
function TagHumanoid(humanoid, player)
local Creator_Tag = Create("ObjectValue"){
Name = "creator",
Value = player,
}
Debris:AddItem(Creator_Tag, 2)
Creator_Tag.Parent = humanoid
end
function UntagHumanoid(humanoid)
for i, v in pairs(humanoid:GetChildren()) do
if v:IsA("ObjectValue") and v.Name == "creator" then
v:Destroy()
end
end
end
function CheckTableForInstance(Table, Instance)
for i, v in pairs(Table) do
if v == Instance then
return true
end
end
return false
end
function GetTotalParts(MaxParts, PossibleParts, Parts)
if MaxParts < PossibleParts then
return MaxParts
elseif Parts >= MaxParts then
return 0
elseif MaxParts >= PossibleParts then
local PartCount = (MaxParts - PossibleParts)
if Parts <= MaxParts then
PartCount = (MaxParts - Parts)
if PartCount > PossibleParts then
return PossibleParts
else
return PartCount
end
elseif PartCount >= PossibleParts then
return PossibleParts
else
return PartCount
end
end
end
function GetParts(Region, MaxParts, Ignore)
local Parts = {}
local RerunFailed = false
while #Parts < MaxParts and not RerunFailed do
local Region = Region
local PossibleParts = GetTotalParts(MaxParts, 3000, #Parts)
local PartsNearby = game:GetService("Workspace"):FindPartsInRegion3WithIgnoreList(Region, Ignore, PossibleParts)
if #PartsNearby == 0 then
RerunFailed = true
else
for i, v in pairs(PartsNearby) do
table.insert(Parts, v)
table.insert(Ignore, v)
end
end
end
return Parts
end
function ApplyDeathEffect(character, Direction, Force)
local Direction = (Direction or Vector3.new(0, 0, 0))
local Force = (Force or Vector3.new(0, 0, 0))
local humanoid = character:FindFirstChild("Humanoid")
if not humanoid then
return
end
local DeathEffectCopy = character:FindFirstChild(DeathEffect.Name)
if DeathEffectCopy then
return
end
DeathEffectCopy = DeathEffect:Clone()
DeathEffectCopy.WindDirection.Value = Direction
DeathEffectCopy.Force.Value = Force
DeathEffectCopy.Disabled = false
DeathEffectCopy.Parent = character
end
function DealDamage(character, damage)
if not CheckIfAlive() or not character then
return
end
local damage = (damage or 0)
local humanoid = character:FindFirstChild("Humanoid")
local rootpart = character:FindFirstChild("HumanoidRootPart")
if not rootpart then
rootpart = character:FindFirstChild("Torso")
end
if not humanoid or humanoid.Health == 0 or not rootpart then
return
end
UntagHumanoid(humanoid)
TagHumanoid(humanoid, Player)
humanoid:TakeDamage(damage)
if humanoid.Health <= 0 then
local WindDir = (CFrame.new(RootPart.Position, Vector3.new(rootpart.Position.X, RootPart.Position.Y, rootpart.Position.Z)) * CFrame.Angles(0, math.pi, 0)).lookVector
ApplyDeathEffect(character, Vector3.new(WindDir.X, 1, WindDir.Z), ((WindDir * 6.5) + Vector3.new(0, 15, 0)))
end
end
function CheckIfAlive()
return (((Character and Character.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0) and true) or false)
end
function Blow(Part)
local PartTouched
local HitDelay = false
PartTouched = Part.Touched:connect(function(Hit)
if not Hit or not Hit.Parent or not CheckIfAlive() or not ToolEquipped or HitDelay then
return
end
local RightArm = Character:FindFirstChild("Right Arm")
if not RightArm then
return
end
local RightGrip = RightArm:FindFirstChild("RightGrip")
if not RightGrip or (RightGrip.Part0 ~= Handle and RightGrip.Part1 ~= Handle) then
return
end
local character = Hit.Parent
if character == Character or (Special.Active and RandomNearby and character ~= RandomNearby.Character) then
return
end
local humanoid = character:FindFirstChild("Humanoid")
local rootpart = character:FindFirstChild("HumanoidRootPart")
if not rootpart then
rootpart = character:FindFirstChild("Torso")
end
if not humanoid or humanoid.Health == 0 or not rootpart then
return
end
local player = Players:GetPlayerFromCharacter(character)
if player and (player == Player or IsTeamMate(Player, player)) then
return
end
HitDelay = true
local TotalDamage = (Damage * ((Special.Active and math.huge) or 1))
DealDamage(character, TotalDamage)
wait(0.05)
HitDelay = false
end)
end
function PossessedAttack()
Fire.Enabled = true
local CurrentlyEquipped = true
if ToolUnequipped then
ToolUnequipped:disconnect()
end
ToolUnequipped = Tool.Unequipped:connect(function()
CurrentlyEquipped = false
end)
local SpecialStart = tick()
while ToolEquipped and CurrentlyEquipped and CheckIfAlive() and (tick() - SpecialStart) < Special.Duration do
local UserPlayer = Player
local UserCharacter = Character
local IgnoreObjects = {UserCharacter, Tool}
local Radius = 35
local Objects = {}
local Humanoids = {}
local PlayersNearby = {}
local NegativeRadius = (RootPart.Position - Vector3.new(Radius, (RootPart.Size.Y * 1.25), Radius))
local PositiveRadius = (RootPart.Position + Vector3.new(Radius, (Radius / 6), Radius))
for i, v in pairs(Players:GetChildren()) do
if v:IsA("Player") and v ~= UserPlayer then
local character = v.Character
if character and character.Parent then
table.insert(IgnoreObjects, v)
if not IsTeamMate(v, UserPlayer) then
local humanoid = character:FindFirstChild("Humanoid")
local rootpart = character:FindFirstChild("HumanoidRootPart")
if not rootpart then
rootpart = character:FindFirstChild("Torso")
end
if humanoid and humanoid.Health > 0 and (RootPart.Position - rootpart.Position).magnitude <= Radius then
table.insert(Humanoids, humanoid)
end
end
end
end
end
if #Humanoids == 0 then
local Parts = GetParts(Region3.new(NegativeRadius, PositiveRadius), 500, IgnoreObjects)
for i, v in pairs(Parts) do
if v and v.Parent and not CheckTableForInstance(Objects, v) then
local character = v.Parent
if character:IsA("Hat") or character:IsA("Tool") then
character = character.Parent
end
local humanoid = character:FindFirstChild("Humanoid")
local player = Players:GetPlayerFromCharacter(character)
if not CheckTableForInstance(Humanoids, humanoid) and not CheckTableForInstance(PlayersNearby, character) then
if humanoid and humanoid.Health > 0 and not CheckTableForInstance(Humanoids, humanoid) then
table.insert(Humanoids, humanoid)
if player and not CheckTableForInstance(PlayersNearby, player) then
table.insert(PlayersNearby, player)
end
elseif (RootPart.Position - v.Position).magnitude <= Radius then
table.insert(Objects, v)
end
end
end
end
end
local NearPlayers = {}
for i, v in pairs(Humanoids) do
local character = v.Parent
local player = Players:GetPlayerFromCharacter(character)
local rootpart = character:FindFirstChild("HumanoidRootPart")
if not rootpart then
rootpart = character:FindFirstChild("Torso")
end
if rootpart then
table.insert(NearPlayers, {Character = character, Humanoid = v, RootPart = rootpart, Distance = (RootPart.Position - rootpart.Position).Magnitude})
end
end
table.sort(NearPlayers, (function(a, b)
return a.Distance < b.Distance
end))
if #NearPlayers > 0 then
local MaxNearbyCount = 3
local MaxNearby = ((#NearPlayers <= MaxNearbyCount and #NearPlayers) or MaxNearbyCount)
RandomNearby = NearPlayers[math.random(1, MaxNearby)]
local OrigPos = RootPart.CFrame
local NewPos = (RandomNearby.RootPart.CFrame * CFrame.new(0, ((RootPart.Size.Z / 2) + (RandomNearby.RootPart.Size.Z / 2) + (RootPart.Size.Y / 2)), ((RootPart.Size.Z / 2) + (RandomNearby.RootPart.Size.Z / 2) + 0.75)))
RootPart.CFrame = CFrame.new(NewPos.p, RandomNearby.RootPart.CFrame.p)
RootPart.Anchored = true
Attack()
wait(1)
RootPart.CFrame = OrigPos
RootPart.Anchored = false
wait(1.5)
end
wait()
end
Fire.Enabled = false
end
function Attack()
Damage = DamageValues.SlashDamage
Sounds.Slash:Play()
--[[local Anim = Create("StringValue"){
Name = "toolanim",
Value = "Slash",
}
Debris:AddItem(Anim, 2)
Anim.Parent = Tool]]
local SwingAnimations = {Animations.LeftSlash, Animations.RightSlash, Animations.SideSwipe, Animations.Swing}
local Animation = SwingAnimations[math.random(1, #SwingAnimations)]
Spawn(function()
InvokeClient("PlayAnimation", Animation)
end)
end
function Lunge()
Damage = DamageValues.LungeDamage
Sounds.Lunge:Play()
for i, v in pairs(Animations) do
Spawn(function()
InvokeClient("StopAnimation", v)
end)
end
local Anim = Create("StringValue"){
Name = "toolanim",
Value = "Lunge",
}
Debris:AddItem(Anim, 2)
Anim.Parent = Tool
wait(0.2)
Tool.Grip = Grips.Out
wait(0.75)
Tool.Grip = Grips.Up
Damage = DamageValues.SlashDamage
end
function Activated()
if not Tool.Enabled or not ToolEquipped or not CheckIfAlive() or Special.Active then
return
end
Tool.Enabled = false
local Tick = RunService.Stepped:wait()
if (Tick - LastAttack < 0.2) then
Lunge()
else
Attack()
end
LastAttack = Tick
--wait(0.5)
Damage = DamageValues.BaseDamage
Tool.Enabled = true
end
function CheckIfAlive()
return (((Player and Player.Parent and Character and Character.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0 and RootPart and RootPart.Parent) and true) or false)
end
function Equipped()
Character = Tool.Parent
Player = Players:GetPlayerFromCharacter(Character)
Humanoid = Character:FindFirstChild("Humanoid")
RootPart = Character:FindFirstChild("HumanoidRootPart")
if not CheckIfAlive() then
return
end
Sounds.Unsheath:Play()
Spawn(function()
if ToolUnequipped then
ToolUnequipped:disconnect()
end
local CurrentlyEquipped = true
ToolUnequipped = Tool.Unequipped:connect(function()
CurrentlyEquipped = false
end)
local Animation = Animations.Equip
Spawn(function()
InvokeClient("PlayAnimation", Animation)
end)
wait(Animation.Duration)
if ToolUnequipped then
ToolUnequipped:disconnect()
end
if not CurrentlyEquipped then
return
end
ToolEquipped = true
Humanoid.WalkSpeed = (16 * 1.5)
end)
end
function Unequipped()
Humanoid.WalkSpeed = 16
ToolEquipped = false
end
function OnServerInvoke(player, mode, value)
if player ~= Player or not ToolEquipped or not value or not CheckIfAlive() then
return
end
if mode == "KeyPressed" then
local Key = string.lower(value.Key)
local Down = value.Down
if Key == "q" and Down then
if not Special.Enabled or Special.Active then
return
end
Special.Enabled = false
Special.Active = true
PossessedAttack()
Special.Active = false
wait(Special.CoolDown)
Special.Enabled = true
end
end
end
function InvokeClient(Mode, Value)
local ClientReturn = nil
pcall(function()
ClientReturn = ClientControl:InvokeClient(Player, Mode, Value)
end)
return ClientReturn
end
ServerControl.OnServerInvoke = OnServerInvoke
Tool.Activated:connect(Activated)
Tool.Equipped:connect(Equipped)
Tool.Unequipped:connect(Unequipped)
Blow(Handle)
|
--------------------------------------------- |
local HoldAnim, ThrowAnim;
Tool.Equipped:connect(function(mouse)
Character = Tool.Parent
Player = game.Players:GetPlayerFromCharacter(Character)
local HoldAnimSrc = WaitFor(Tool).HoldAnim()
HoldAnimSrc.AnimationId = 'http://www.roblox.com/asset/?id=88743592'
local ThrowAnimSrc = WaitFor(Tool).ThrowAnim()
ThrowAnimSrc.AnimationId = 'http://www.roblox.com/asset/?id=88743566'
HoldAnim = Character.Humanoid:LoadAnimation(HoldAnimSrc)
ThrowAnim = Character.Humanoid:LoadAnimation(ThrowAnimSrc)
--setup first anim / cursor cycle
if Now() > NextFireAt.Value then
Handle.Transparency = 0
mouse.Icon = 'rbxasset://textures\\GunCursor.png'
HoldAnim:Play()
else
Handle.Transparency = 1
Delay(NextFireAt.Value - Now(), function()
mouse.Icon = 'rbxasset://textures\\GunWaitCursor.png'
Handle.Transparency = 0
HoldAnim:Play()
end)
end
mouse.Button1Down:connect(function()
--we track the reload time like this so that the player can't fire faster with
--rapid dis / re-equipping, which will actually be common usage with this gear.
if Now() > NextFireAt.Value then
NextFireAt.Value = Now() + RELOAD_TIME
--
local gr = Handle:Clone()
gr.CanCollide = false
local sc = GrenadeScript:Clone()
sc.Parent = gr
sc.Disabled = false
WaitFor(sc).creator().Value = Player
--calc velocity
local toTarget = mouse.Hit.p - gr.Position
local dy = toTarget.y
toTarget = Vector3.new(toTarget.x, 0, toTarget.z)
local dx = toTarget.magnitude
toTarget = toTarget.unit
Velocity = math.min(120, 40 + dx)
local theta = computeLaunchAngle(dx, dy, 196.2)
local vY = math.sin(theta)*Velocity
local vX = toTarget.x * math.cos(theta) * Velocity
local vZ = toTarget.z * math.cos(theta) * Velocity
gr.CanCollide = false
Delay(0.1, function()
gr.CanCollide = true
end)
gr.Velocity = Vector3.new(vX, vY, vZ)
gr.Parent = game.Workspace
--play sound / anim
ThrowSound:Play()
HoldAnim:Stop(0)
ThrowAnim:Play(0,1,1)
--reload
Handle.Transparency = 1
mouse.Icon = 'rbxasset://textures\\GunWaitCursor.png'
wait(RELOAD_TIME)
HoldAnim:Play()
Handle.Transparency = 0
mouse.Icon = 'rbxasset://textures\\GunCursor.png'
end
end)
end)
Tool.Unequipped:connect(function()
if ThrowSound then
ThrowSound:Stop()
end
if ThrowAnim then
ThrowAnim:Stop()
end
if HoldAnim then
HoldAnim:Stop()
end
end)
|
--important stuff to register what is what. you need these if you want to do stuff with the tool itself. |
Tool.Activated:connect(Activated)
Tool.Equipped:connect(Equipped)
Tool.Unequipped:connect(Unequipped)
for i,D in pairs(script.Parent:GetChildren()) do
if D.Name == "DP" then
if b == false then
if dmg == true then
b = true
D.Touched:connect(Blow)
wait(1)
b = false
end
end
end
end
|
--Services |
local PathfindingService = game:GetService("PathfindingService")
|
--//Controller//-- |
Spawners:Activate()
RunService.RenderStepped:Connect(function()
if not DBOn then
if Camera.CameraType ~= Enum.CameraType.Scriptable then
Camera.CameraType = Enum.CameraType.Scriptable
end
Camera.CFrame = CamPart.CFrame
end
end)
|
-- scr.Disabled= false |
-- запускаем его в направлении пушки (смещаем в неправлении взгляда) |
-- Properties |
local OptimalEffects = true
local RenderDistance = 400
local ScreenCullingEnabled = true
local ScreenCullingRadius = 16
FastCast.DebugLogging = false
FastCast.VisualizeCasts = false
FastCast.RayExit = true -- Only applies for Wall Penetration.
local Beam = Instance.new("Beam")
Beam.TextureSpeed = 0
Beam.LightEmission = 0
Beam.LightInfluence = 1
Beam.Transparency = NumberSequence.new(0)
local Caster = FastCast.new()
local function MakeImpactFX(Hit, Position, Normal, Material, ParentToPart, HitEffectData, BulletHoleData, ClientData)
if Hit ~= nil and Position ~= nil and Normal ~= nil then
local SurfaceCF = CFrame.new(Position, Position + Normal)
if HitEffectData[1] then
local Attachment = Instance.new("Attachment")
Attachment.CFrame = SurfaceCF
Attachment.Parent = Workspace.Terrain
local Sound
local function Spawner(material)
if HitEffectData[6][material.Name]:FindFirstChild("MaterialSounds") then
local tracks = HitEffectData[6][material.Name].MaterialSounds:GetChildren()
local rn = math.random(1, #tracks)
local track = tracks[rn]
if track ~= nil then
Sound = track:Clone()
if track:FindFirstChild("Pitch") then
Sound.PlaybackSpeed = Random.new():NextNumber(track.Pitch.Min.Value, track.Pitch.Max.Value)
else
Sound.PlaybackSpeed = Random.new():NextNumber(HitEffectData[3], HitEffectData[4])
end
if track:FindFirstChild("Volume") then
Sound.Volume = Random.new():NextNumber(track.Volume.Min.Value, track.Volume.Max.Value)
else
Sound.Volume = HitEffectData[5]
end
Sound.Parent = Attachment
end
else
Sound = Instance.new("Sound",Attachment)
Sound.SoundId = "rbxassetid://"..HitEffectData[2][math.random(1, #HitEffectData[2])]
Sound.PlaybackSpeed = Random.new():NextNumber(HitEffectData[3], HitEffectData[4])
Sound.Volume = HitEffectData[5]
end
for i, v in pairs(HitEffectData[6][material.Name]:GetChildren()) do
if v.ClassName == "ParticleEmitter" then
local Count = 1
local Particle = v:Clone()
Particle.Parent = Attachment
if Particle:FindFirstChild("EmitCount") then
Count = Particle.EmitCount.Value
end
if Particle.PartColor.Value then
local HitPartColor = Hit and Hit.Color or Color3.fromRGB(255, 255, 255)
if Hit and Hit:IsA("Terrain") then
HitPartColor = Workspace.Terrain:GetMaterialColor(Material or Enum.Material.Sand)
end
Particle.Color = ColorSequence.new(HitPartColor, HitPartColor)
end
Thread:Delay(0.01, function()
if OptimalEffects then
local QualityLevel = UserSettings().GameSettings.SavedQualityLevel
if QualityLevel == Enum.SavedQualitySetting.Automatic then
local Compressor = 1 / 2
Particle:Emit(Count * Compressor)
else
local Compressor = QualityLevel.Value / 21
Particle:Emit(Count * Compressor)
end
else
Particle:Emit(Count)
end
Debris:AddItem(Particle, Particle.Lifetime.Max)
end)
end
end
Sound:Play()
if BulletHoleData[1] then
local Hole = Instance.new("Attachment")
Hole.Parent = ParentToPart and Hit or Workspace.Terrain
Hole.WorldCFrame = SurfaceCF * CFrame.Angles(math.rad(90), math.rad(180), 0)
if ParentToPart then
local Scale = BulletHoleData[2]
if HitEffectData[6][material.Name]:FindFirstChild("MaterialHoleSize") then
Scale = HitEffectData[6][material.Name].MaterialHoleSize.Value
end
local A0 = Instance.new("Attachment")
local A1 = Instance.new("Attachment")
local BeamClone = Beam:Clone()
BeamClone.Width0 = Scale
BeamClone.Width1 = Scale
if HitEffectData[6][material.Name]:FindFirstChild("MaterialDecals") then
local Decals = HitEffectData[6][material.Name].MaterialDecals:GetChildren()
local Chosen = math.random(1, #Decals)
local Decal = Decals[Chosen]
if Decal ~= nil then
BeamClone.Texture = "rbxassetid://"..Decal.Value
if Decal.PartColor.Value then
local HitPartColor = Hit and Hit.Color or Color3.fromRGB(255, 255, 255)
if Hit and Hit:IsA("Terrain") then
HitPartColor = Workspace.Terrain:GetMaterialColor(Material or Enum.Material.Sand)
end
BeamClone.Color = ColorSequence.new({ColorSequenceKeypoint.new(0, HitPartColor), ColorSequenceKeypoint.new(1, HitPartColor)})
end
end
else
BeamClone.Texture = "rbxassetid://"..BulletHoleData[3][math.random(1, #BulletHoleData[3])]
if BulletHoleData[4] then
local HitPartColor = Hit and Hit.Color or Color3.fromRGB(255, 255, 255)
if Hit and Hit:IsA("Terrain") then
HitPartColor = Workspace.Terrain:GetMaterialColor(Material or Enum.Material.Sand)
end
BeamClone.Color = ColorSequence.new({ColorSequenceKeypoint.new(0, HitPartColor), ColorSequenceKeypoint.new(1, HitPartColor)})
end
end
BeamClone.Attachment0 = A0
BeamClone.Attachment1 = A1
A0.Parent = Hit
A1.Parent = Hit
A0.WorldCFrame = Hole.WorldCFrame * CFrame.new(Scale / 2, -0.01, 0) * CFrame.Angles(math.rad(90), 0, 0)
A1.WorldCFrame = Hole.WorldCFrame * CFrame.new(-Scale / 2, -0.01, 0) * CFrame.Angles(math.rad(90), math.rad(180), 0)
BeamClone.Parent = Workspace.Terrain
Thread:Delay(BulletHoleData[5], function()
if BulletHoleData[5] > 0 then
if OptimalEffects then
if ClientData then
local t0 = os.clock()
while Hole ~= nil do
local Alpha = math.min((os.clock() - t0) / BulletHoleData[6], 1)
if BeamClone then BeamClone.Transparency = NumberSequence.new(Math.Lerp(0, 1, Alpha)) end
if Alpha == 1 then break end
Thread:Wait()
end
if A0 then A0:Destroy() end
if A1 then A1:Destroy() end
if BeamClone then BeamClone:Destroy() end
if Hole then Hole:Destroy() end
else
if A0 then A0:Destroy() end
if A1 then A1:Destroy() end
if BeamClone then BeamClone:Destroy() end
if Hole then Hole:Destroy() end
end
else
local t0 = os.clock()
while Hole ~= nil do
local Alpha = math.min((os.clock() - t0) / BulletHoleData[6], 1)
if BeamClone then BeamClone.Transparency = NumberSequence.new(Math.Lerp(0, 1, Alpha)) end
if Alpha == 1 then break end
Thread:Wait()
end
if A0 then A0:Destroy() end
if A1 then A1:Destroy() end
if BeamClone then BeamClone:Destroy() end
if Hole then Hole:Destroy() end
end
else
if A0 then A0:Destroy() end
if A1 then A1:Destroy() end
if BeamClone then BeamClone:Destroy() end
if Hole then Hole:Destroy() end
end
end)
else
Debris:AddItem(Hole, 5)
end
end
end
if not HitEffectData[7] then
if HitEffectData[6]:FindFirstChild(Hit.Material) then
Spawner(Hit.Material)
else
Spawner(HitEffectData[6].Custom)
end
else
Spawner(HitEffectData[6].Custom)
end
Debris:AddItem(Attachment, 10)
end
end
end
local function MakeBloodFX(Hit, Position, Normal, Material, ParentToPart, BloodEffectData, ClientData)
if Hit ~= nil and Position ~= nil and Normal ~= nil then
local SurfaceCF = CFrame.new(Position, Position + Normal)
if BloodEffectData[1] then
local Attachment = Instance.new("Attachment")
Attachment.CFrame = SurfaceCF
Attachment.Parent = Workspace.Terrain
local Sound = Instance.new("Sound",Attachment)
Sound.SoundId = "rbxassetid://"..BloodEffectData[2][math.random(1, #BloodEffectData[2])]
Sound.PlaybackSpeed = Random.new():NextNumber(BloodEffectData[3], BloodEffectData[4])
Sound.Volume = BloodEffectData[5]
local function Spawner()
local C = BloodEffectData[6]:GetChildren()
for i, v in pairs(BloodEffectData[6]:GetChildren()) do
if v.ClassName == "ParticleEmitter" then
local Count = 1
local Particle = C[i]:Clone()
Particle.Parent = Attachment
if Particle:FindFirstChild("EmitCount") then
Count = Particle.EmitCount.Value
end
Thread:Delay(0.01, function()
if OptimalEffects then
local QualityLevel = UserSettings().GameSettings.SavedQualityLevel
if QualityLevel == Enum.SavedQualitySetting.Automatic then
local Compressor = 1 / 2
Particle:Emit(Count * Compressor)
else
local Compressor = QualityLevel.Value / 21
Particle:Emit(Count * Compressor)
end
else
Particle:Emit(Count)
end
Debris:AddItem(Particle, Particle.Lifetime.Max)
end)
end
end
Sound:Play()
end
Thread:Spawn(Spawner)
Debris:AddItem(Attachment, 10)
end
if BloodEffectData[7][1] then
local Hole = Instance.new("Attachment")
Hole.Parent = ParentToPart and Hit or Workspace.Terrain
Hole.WorldCFrame = SurfaceCF * CFrame.Angles(math.rad(90), math.rad(180), 0)
if ParentToPart then
local Scale = BloodEffectData[7][2]
local A0 = Instance.new("Attachment")
local A1 = Instance.new("Attachment")
local BeamClone = Beam:Clone()
BeamClone.Width0 = Scale
BeamClone.Width1 = Scale
BeamClone.Texture = "rbxassetid://"..BloodEffectData[7][3][math.random(1, #BloodEffectData[7][3])]
BeamClone.Color = ColorSequence.new({ColorSequenceKeypoint.new(0, BloodEffectData[7][4]), ColorSequenceKeypoint.new(1, BloodEffectData[7][4])})
if BloodEffectData[7][7] then
local HitPartColor = Hit and Hit.Color or Color3.fromRGB(255, 255, 255)
if Hit and Hit:IsA("Terrain") then
HitPartColor = Workspace.Terrain:GetMaterialColor(Material or Enum.Material.Sand)
end
BeamClone.Color = ColorSequence.new({ColorSequenceKeypoint.new(0, HitPartColor), ColorSequenceKeypoint.new(1, HitPartColor)})
end
BeamClone.Attachment0 = A0
BeamClone.Attachment1 = A1
A0.Parent = Hit
A1.Parent = Hit
A0.WorldCFrame = Hole.WorldCFrame * CFrame.new(Scale / 2, -0.01, 0) * CFrame.Angles(math.rad(90), 0, 0)
A1.WorldCFrame = Hole.WorldCFrame * CFrame.new(-Scale / 2, -0.01, 0) * CFrame.Angles(math.rad(90), math.rad(180), 0)
BeamClone.Parent = Workspace.Terrain
Thread:Delay(BloodEffectData[7][5], function()
if BloodEffectData[7][5] > 0 then
if OptimalEffects then
if ClientData then
local t0 = os.clock()
while Hole ~= nil do
local Alpha = math.min((os.clock() - t0) / BloodEffectData[7][6], 1)
if BeamClone then BeamClone.Transparency = NumberSequence.new(Math.Lerp(0, 1, Alpha)) end
if Alpha == 1 then break end
Thread:Wait()
end
if A0 then A0:Destroy() end
if A1 then A1:Destroy() end
if BeamClone then BeamClone:Destroy() end
if Hole then Hole:Destroy() end
else
if A0 then A0:Destroy() end
if A1 then A1:Destroy() end
if BeamClone then BeamClone:Destroy() end
if Hole then Hole:Destroy() end
end
else
local t0 = os.clock()
while Hole ~= nil do
local Alpha = math.min((os.clock() - t0) / BloodEffectData[7][6], 1)
if BeamClone then BeamClone.Transparency = NumberSequence.new(Math.Lerp(0, 1, Alpha)) end
if Alpha == 1 then break end
Thread:Wait()
end
if A0 then A0:Destroy() end
if A1 then A1:Destroy() end
if BeamClone then BeamClone:Destroy() end
if Hole then Hole:Destroy() end
end
else
if A0 then A0:Destroy() end
if A1 then A1:Destroy() end
if BeamClone then BeamClone:Destroy() end
if Hole then Hole:Destroy() end
end
end)
else
Debris:AddItem(Hole, 5)
end
end
end
end
local function OnRayHit(origin, direction, hitPart, hitPoint, normal, material, segmentVelocity, cosmeticBulletObject, hitData)
local ShowEffects = ScreenCullingEnabled and (ScreenCulling(hitPoint, ScreenCullingRadius) and (hitPoint - Camera.CFrame.p).Magnitude <= RenderDistance) or (hitPoint - Camera.CFrame.p).Magnitude <= RenderDistance
cosmeticBulletObject.Transparency = 1
for i, v in pairs(cosmeticBulletObject:GetDescendants()) do
if (v:IsA("BasePart") or v:IsA("Decal") or v:IsA("Texture")) then
v.Transparency = 1
elseif v:IsA("ParticleEmitter") then
v.Enabled = false
elseif v:IsA("Sound") then
v:Stop()
elseif v:IsA("PointLight") then
v.Enabled = false
--[[elseif v:IsA("Trail") then -- There is a case that trail is barely visible when projectile hits (especially at high speed). So I marked it as comment.
v.Enabled = false]]
elseif v:IsA("Beam") then
v.Enabled = false
end
end
Debris:AddItem(cosmeticBulletObject, 5) -- 10
if not hitData[1][1] then
if hitPart ~= nil and hitPart.Parent ~= nil then
if hitData[6] ~= nil and hitPart.Name == "_glass" then
ShatterGlass:FireServer(hitPart, hitPoint, direction)
else
local Distance = (hitPoint - origin).Magnitude
local Target = hitPart:FindFirstAncestorOfClass("Model")
local TargetHumanoid = Target and Target:FindFirstChildOfClass("Humanoid")
local TargetTorso = Target and (Target:FindFirstChild("HumanoidRootPart") or Target:FindFirstChild("Head"))
local Tagger = Players:GetPlayerFromCharacter(hitData[5].Parent)
if TargetHumanoid and TargetHumanoid.Health > 0 and TargetTorso then
if ShowEffects then MakeBloodFX(hitPart, hitPoint, normal, material, true, hitData[4], hitData[6]) end
if hitData[6] ~= nil then
if TargetHumanoid.Health > 0 then
Thread:Spawn(function()
InflictTarget:InvokeServer(hitData[7], hitData[5],
Tagger,
TargetHumanoid,
TargetTorso,
{hitData[6][1][1], hitData[6][1][2], hitData[6][1][3],Distance, hitData[6][1][4], hitData[6][1][5], hitData[6][1][6], hitData[6][1][7]},
{hitData[6][2][1], hitData[6][2][2], hitData[6][2][3], hitData[6][2][4], hitData[6][2][5]},
{hitData[6][3][1], hitData[6][3][2], hitData[6][3][3]},
hitPart,
{hitData[6][4][1], hitData[6][4][2], hitData[6][4][3], hitData[6][4][4], hitData[6][4][5], hitData[6][4][6], hitData[6][4][7]})
end)
if hitData[5].GunScript_Local:FindFirstChild("MarkerEvent") then
hitData[5].GunScript_Local.MarkerEvent:Fire(hitPart.Name == "Head" and hitData[6][1][3])
end
end
end
else
if ShowEffects then
MakeImpactFX(hitPart, hitPoint, normal, material, true, hitData[2], hitData[3], hitData[6])
end
end
end
end
else
if hitData[1][3] then
local Attachment = Instance.new("Attachment")
Attachment.CFrame = CFrame.new(hitPoint)
Attachment.Parent = Workspace.Terrain
local Sound = Instance.new("Sound")
Sound.SoundId = "rbxassetid://"..hitData[1][4][math.random(1, #hitData[1][4])]
Sound.PlaybackSpeed = Random.new():NextNumber(hitData[1][5], hitData[1][6])
Sound.Volume = hitData[1][7]
Sound.Parent = Attachment
Sound:Play()
Debris:AddItem(Attachment, 10)
end
local Explosion = Instance.new("Explosion")
Explosion.BlastRadius = hitData[1][2]
Explosion.BlastPressure = 0
Explosion.ExplosionType = Enum.ExplosionType.NoCraters
Explosion.Position = hitPoint ~= nil and hitPoint or cosmeticBulletObject.Position
Explosion.Parent = Camera
local SurfaceCF = hitPart ~= nil and hitPoint ~= nil and normal ~= nil and CFrame.new(hitPoint, hitPoint + normal) or cosmeticBulletObject.CFrame
if ShowEffects and hitPart ~= nil and hitPoint ~= nil and normal ~= nil then
if hitData[1][11] then
local Target = hitPart:FindFirstAncestorOfClass("Model")
if hitPart and not hitPart.Parent or not (Target and Target:FindFirstChildOfClass("Humanoid")) then
local ParentToPart = true
local Hole = Instance.new("Attachment")
Hole.Parent = ParentToPart and hitPart or Workspace.Terrain
Hole.WorldCFrame = SurfaceCF * CFrame.Angles(math.rad(90), math.rad(180), 0)
if ParentToPart then
local Scale = hitData[1][12]
local A0 = Instance.new("Attachment")
local A1 = Instance.new("Attachment")
local BeamClone = Beam:Clone()
BeamClone.Width0 = Scale
BeamClone.Width1 = Scale
BeamClone.Texture = "rbxassetid://"..hitData[1][13][math.random(1, #hitData[1][13])]
if hitData[1][14] then
local HitPartColor = hitPart and hitPart.Color or Color3.fromRGB(255, 255, 255)
if hitPart and hitPart:IsA("Terrain") then
HitPartColor = Workspace.Terrain:GetMaterialColor(material or Enum.Material.Sand)
end
BeamClone.Color = ColorSequence.new({ColorSequenceKeypoint.new(0, HitPartColor), ColorSequenceKeypoint.new(1, HitPartColor)})
end
BeamClone.Attachment0 = A0
BeamClone.Attachment1 = A1
A0.Parent = hitPart
A1.Parent = hitPart
A0.WorldCFrame = Hole.WorldCFrame * CFrame.new(Scale / 2, -0.01, 0) * CFrame.Angles(math.rad(90), 0, 0)
A1.WorldCFrame = Hole.WorldCFrame * CFrame.new(-Scale / 2, -0.01, 0) * CFrame.Angles(math.rad(90), math.rad(180), 0)
BeamClone.Parent = workspace.Terrain
Thread:Delay(hitData[1][15], function()
if hitData[1][15] > 0 then
if OptimalEffects then
if hitData[6] then
local t0 = os.clock()
while Hole ~= nil do
local Alpha = math.min((os.clock() - t0) / hitData[1][16], 1)
if BeamClone then BeamClone.Transparency = NumberSequence.new(Math.Lerp(0, 1, Alpha)) end
if Alpha == 1 then break end
Thread:Wait()
end
if A0 then A0:Destroy() end
if A1 then A1:Destroy() end
if BeamClone then BeamClone:Destroy() end
if Hole then Hole:Destroy() end
else
if A0 then A0:Destroy() end
if A1 then A1:Destroy() end
if BeamClone then BeamClone:Destroy() end
if Hole then Hole:Destroy() end
end
else
local t0 = os.clock()
while Hole ~= nil do
local Alpha = math.min((os.clock() - t0) / hitData[1][16], 1)
if BeamClone then BeamClone.Transparency = NumberSequence.new(Math.Lerp(0, 1, Alpha)) end
if Alpha == 1 then break end
Thread:Wait()
end
if A0 then A0:Destroy() end
if A1 then A1:Destroy() end
if BeamClone then BeamClone:Destroy() end
if Hole then Hole:Destroy() end
end
else
if A0 then A0:Destroy() end
if A1 then A1:Destroy() end
if BeamClone then BeamClone:Destroy() end
if Hole then Hole:Destroy() end
end
end)
else
Debris:AddItem(Hole, 5)
end
end
end
end
if hitData[1][8] then
Explosion.Visible = false
if ShowEffects then
local Attachment = Instance.new("Attachment")
Attachment.CFrame = SurfaceCF
Attachment.Parent = Workspace.Terrain
local function Spawner()
for i, v in pairs(hitData[1][9]:GetChildren()) do
if v.ClassName == "ParticleEmitter" then
local Count = 1
local Particle = v:Clone()
Particle.Parent = Attachment
if Particle:FindFirstChild("EmitCount") then
Count = Particle.EmitCount.Value
end
Thread:Delay(0.01, function()
if OptimalEffects then
local QualityLevel = UserSettings().GameSettings.SavedQualityLevel
if QualityLevel == Enum.SavedQualitySetting.Automatic then
local Compressor = 1 / 2
Particle:Emit(Count * Compressor)
else
local Compressor = QualityLevel.Value / 21
Particle:Emit(Count * Compressor)
end
else
Particle:Emit(Count)
end
Debris:AddItem(Particle, Particle.Lifetime.Max)
end)
end
end
end
Thread:Spawn(Spawner)
Debris:AddItem(Attachment, 10)
end
end
local HitHumanoids = {}
Explosion.Hit:Connect(function(HitPart, HitDist)
if HitPart and hitData[6] ~= nil then
if HitPart.Parent and HitPart.Name == "HumanoidRootPart" or HitPart.Name == "Head" then
local Distance = (hitPoint - origin).Magnitude
local Target = HitPart:FindFirstAncestorOfClass("Model")
local TargetHumanoid = Target and Target:FindFirstChildOfClass("Humanoid")
local TargetTorso = Target and (Target:FindFirstChild("HumanoidRootPart") or Target:FindFirstChild("Head"))
local Tagger = Players:GetPlayerFromCharacter(hitData[5].Parent)
if TargetHumanoid then
if TargetHumanoid.Health > 0 then
if not HitHumanoids[TargetHumanoid] then
if hitData[1][17] then
local Multipler = hitData[1][20]
local DistanceFactor = HitDist / hitData[1][2]
DistanceFactor = 1 - DistanceFactor
local VelocityMod = (TargetTorso.Position - Explosion.Position).Unit * hitData[1][18] --* DistanceFactor
local AirVelocity = TargetTorso.Velocity - Vector3.new(0, TargetTorso.Velocity.y, 0) + Vector3.new(VelocityMod.X, 0, VelocityMod.Z)
if DamageModule.CanDamage(Target, hitData[5].Parent, hitData[6][1][7]) then
local TorsoFly = Instance.new("BodyVelocity")
TorsoFly.MaxForce = Vector3.new(math.huge, 0, math.huge)
TorsoFly.Velocity = AirVelocity
TorsoFly.Parent = TargetTorso
TargetTorso.Velocity = TargetTorso.Velocity + Vector3.new(0, VelocityMod.Y * Multipler, 0)
Debris:AddItem(TorsoFly, 0.25)
else
if TargetHumanoid.Parent.Name == Tagger.Name then
Multipler = hitData[1][19]
local TorsoFly = Instance.new("BodyVelocity")
TorsoFly.MaxForce = Vector3.new(math.huge, 0, math.huge)
TorsoFly.Velocity = AirVelocity
TorsoFly.Parent = TargetTorso
TargetTorso.Velocity = TargetTorso.Velocity + Vector3.new(0, VelocityMod.Y * Multipler, 0)
Debris:AddItem(TorsoFly, 0.25)
end
end
end
Thread:Spawn(function()
InflictTarget:InvokeServer(hitData[7], hitData[5],
Tagger,
TargetHumanoid,
TargetTorso,
{hitData[6][1][1], hitData[6][1][2], hitData[6][1][3], Distance, hitData[6][1][4], hitData[6][1][5], hitData[6][1][6], hitData[6][1][7]},
{hitData[6][2][1], hitData[6][2][2], hitData[6][2][3], hitData[6][2][4], hitData[6][2][5]},
{hitData[6][3][1], hitData[6][3][2], hitData[6][3][3]},
HitPart,
{hitData[6][4][1], hitData[6][4][2], hitData[6][4][3], hitData[6][4][4], hitData[6][4][5], hitData[6][4][6], hitData[6][4][7]},
{hitData[1][1], hitData[1][2], HitDist, hitData[1][10], hitData[1][21], hitData[1][22], hitData[1][23]})
end)
if hitData[5].GunScript_Local:FindFirstChild("MarkerEvent") then
hitData[5].GunScript_Local.MarkerEvent:Fire(HitPart.Name == "Head" and hitData[6][1][3])
end
HitHumanoids[TargetHumanoid] = true
end
end
end
elseif HitPart.Name == "_glass" then
ShatterGlass:FireServer(HitPart, HitPart.Position, direction)
end
end
end)
end
end
local function CanRayPenetrate(origin, direction, hitPart, hitPoint, normal, material, segmentVelocity, hitData)
-- This function shows off the penetrating feature. Pass this function as the last argument (after bulletAcceleration) and it will run this every time the ray runs into an object
local ShowEffects = ScreenCullingEnabled and (ScreenCulling(hitPoint, ScreenCullingRadius) and (hitPoint - Camera.CFrame.p).Magnitude <= RenderDistance) or (hitPoint - Camera.CFrame.p).Magnitude <= RenderDistance
if hitPart ~= nil and hitPart.Parent ~= nil then
if hitData[6] ~= nil and hitPart.Name == "_glass" then
ShatterGlass:FireServer(hitPart, hitPoint, direction)
return "penetratedObject" -- Penetrate Object
else
local Distance = (hitPoint - origin).Magnitude
local Target = hitPart:FindFirstAncestorOfClass("Model")
local TargetHumanoid = Target and Target:FindFirstChildOfClass("Humanoid")
local TargetTorso = Target and (Target:FindFirstChild("HumanoidRootPart") or Target:FindFirstChild("Head"))
local Tagger = Players:GetPlayerFromCharacter(hitData[5].Parent)
if TargetHumanoid and TargetHumanoid.Health > 0 and TargetTorso then
if ShowEffects then MakeBloodFX(hitPart, hitPoint, normal, material, true, hitData[4], hitData[6]) end
if hitData[6] ~= nil then
if TargetHumanoid.Health > 0 then
Thread:Spawn(function()
InflictTarget:InvokeServer(hitData[7], hitData[5],
Tagger,
TargetHumanoid,
TargetTorso,
{hitData[6][1][1], hitData[6][1][2], hitData[6][1][3], Distance, hitData[6][1][4], hitData[6][1][5], hitData[6][1][6], hitData[6][1][7]},
{hitData[6][2][1], hitData[6][2][2], hitData[6][2][3], hitData[6][2][4], hitData[6][2][5]},
{hitData[6][3][1], hitData[6][3][2], hitData[6][3][3]},
hitPart,
{hitData[6][4][1], hitData[6][4][2], hitData[6][4][3], hitData[6][4][4], hitData[6][4][5], hitData[6][4][6], hitData[6][4][7]})
end)
if hitData[5].GunScript_Local:FindFirstChild("MarkerEvent") then
hitData[5].GunScript_Local.MarkerEvent:Fire(hitPart.Name == "Head" and hitData[6][1][3])
end
end
end
return "penetratedHumanoid" -- Penetrate Humanoid
else
if ShowEffects then MakeImpactFX(hitPart, hitPoint, normal, material, true, hitData[2], hitData[3], hitData[6]) end
return "penetratedObject" -- Penetrate Object
end
end
end
end
local function CanRayPenetrateHumanoid(origin, direction, hitPart, hitPoint, normal, material, segmentVelocity, penetrationAmount, hitData)
-- This function shows off the penetrating feature. Pass this function as the last argument (after bulletAcceleration) and it will run this every time the ray runs into an object
local ShowEffects = ScreenCullingEnabled and (ScreenCulling(hitPoint, ScreenCullingRadius) and (hitPoint - Camera.CFrame.p).Magnitude <= RenderDistance) or (hitPoint - Camera.CFrame.p).Magnitude <= RenderDistance
if hitPart ~= nil and hitPart.Parent ~= nil then
if (hitPart.Transparency > 0.75
or hitPart.Name == "Handle"
or hitPart.Name == "Effect"
or hitPart.Name == "Bullet"
or hitPart.Name == "Laser"
or string.lower(hitPart.Name) == "water"
or hitPart.Name == "Rail"
or hitPart.Name == "Arrow"
or (hitPart.Parent:FindFirstChild("Humanoid") and hitPart.Parent.Humanoid.Health == 0)) then
return true -- Penetrate Blacklisted Object
else
local Distance = (hitPoint - origin).Magnitude
local Target = hitPart:FindFirstAncestorOfClass("Model")
local TargetHumanoid = Target and Target:FindFirstChildOfClass("Humanoid")
local TargetTorso = Target and (Target:FindFirstChild("HumanoidRootPart") or Target:FindFirstChild("Head"))
local Tagger = Players:GetPlayerFromCharacter(hitData[5].Parent)
if TargetHumanoid and TargetHumanoid.Health > 0 and TargetTorso then
if penetrationAmount > 0 then
if ShowEffects then MakeBloodFX(hitPart, hitPoint, normal, material, true, hitData[4], hitData[6]) end
if hitData[6] ~= nil then
if TargetHumanoid.Health > 0 then
Thread:Spawn(function()
InflictTarget:InvokeServer(hitData[7], hitData[5],
Tagger,
TargetHumanoid,
TargetTorso,
{hitData[6][1][1], hitData[6][1][2], hitData[6][1][3], Distance, hitData[6][1][4], hitData[6][1][5], hitData[6][1][6], hitData[6][1][7]},
{hitData[6][2][1], hitData[6][2][2], hitData[6][2][3], hitData[6][2][4], hitData[6][2][5]},
{hitData[6][3][1], hitData[6][3][2], hitData[6][3][3]},
hitPart,
{hitData[6][4][1], hitData[6][4][2], hitData[6][4][3], hitData[6][4][4], hitData[6][4][5], hitData[6][4][6], hitData[6][4][7]})
end)
if hitData[5].GunScript_Local:FindFirstChild("MarkerEvent") then
hitData[5].GunScript_Local.MarkerEvent:Fire(hitPart.Name == "Head" and hitData[6][1][3])
end
end
end
end
return true -- Penetrate Humanoid
--[[else
-- We must check if penetrationAmount reachs 0
if penetrationAmount <= 0 then
MakeImpactFX(hitPart, hitPoint, normal, material, true, hitData[2], hitData[3], hitData[6])
end]]
end
end
end
return false -- Can't penetrate
end
local function OnRayExited(origin, direction, hitPart, hitPoint, normal, material, segmentVelocity, hitData)
local ShowEffects = ScreenCullingEnabled and (ScreenCulling(hitPoint, ScreenCullingRadius) and (hitPoint - Camera.CFrame.p).Magnitude <= RenderDistance) or (hitPoint - Camera.CFrame.p).Magnitude <= RenderDistance
if hitPart.Name == "_glass" then
return
else
local Target = hitPart:FindFirstAncestorOfClass("Model")
local TargetHumanoid = Target and Target:FindFirstChildOfClass("Humanoid")
local TargetTorso = Target and (Target:FindFirstChild("HumanoidRootPart") or Target:FindFirstChild("Head"))
if TargetHumanoid and TargetHumanoid.Health > 0 and TargetTorso then
if ShowEffects then MakeBloodFX(hitPart, hitPoint, normal, material, true, hitData[4], hitData[6]) end
else
if ShowEffects then MakeImpactFX(hitPart, hitPoint, normal, material, true, hitData[2], hitData[3], hitData[6]) end
end
end
end
local function OnRayUpdated(castOrigin, segmentOrigin, segmentDirection, length, segmentVelocity, cosmeticBulletObject, bulletData, whizData, hitData)
-- Whenever the caster steps forward by one unit, this function is called
-- The bullet argument is the same object passed into the fire function
local bulletLength = cosmeticBulletObject.Size.Z / 2 -- This is used to move the bullet to the right spot based on a CFrame offset
local baseCFrame = CFrame.new(segmentOrigin, segmentOrigin + segmentDirection)
if bulletData[1] then
cosmeticBulletObject.CFrame = baseCFrame * CFrame.new(0, 0, -(length - bulletLength)) * CFrame.Angles(math.rad(-360 * (os.clock() * bulletData[2] - math.floor(os.clock() * bulletData[2]))), math.rad(-360 * (os.clock() * bulletData[3] - math.floor(os.clock() * bulletData[3]))), math.rad(-360 * (os.clock() * bulletData[4] - math.floor(os.clock() * bulletData[4]))))
else
cosmeticBulletObject.CFrame = baseCFrame * CFrame.new(0, 0, -(length - bulletLength))
end
if hitData[6] == nil and whizData[1] and cosmeticBulletObject.Parent and cosmeticBulletObject:FindFirstChild("Whizzed") then
local Whizzed = cosmeticBulletObject:FindFirstChild("Whizzed")
if not Whizzed.Value then
local Mag = (Camera.CFrame.p - cosmeticBulletObject.Position).Magnitude
if Mag < whizData[5] then
--local Loudness = 1 - (mag / whizData[5])
local WhizSound = Instance.new("Sound")
WhizSound.SoundId = "rbxassetid://"..whizData[2][math.random(1, #whizData[2])]
WhizSound.Volume = whizData[6] --Loudness
WhizSound.PlaybackSpeed = Random.new():NextNumber(whizData[3], whizData[4])
WhizSound.Name = "WhizSound"
WhizSound.Parent = SoundService
WhizSound:Play()
Debris:AddItem(WhizSound, WhizSound.TimeLength / WhizSound.PlaybackSpeed)
Whizzed.Value = true
end
end
end
end
function ProjectileHandler:VisualizeHitEffect(Type, Replicate, Hit, Position, Normal, Material, ...)
if Replicate then
VisualizeHitEffect:FireServer(Type, nil, Hit, Position, Normal, Material, ...)
end
local ShowEffects = ScreenCullingEnabled and (ScreenCulling(Position, ScreenCullingRadius) and (Position - Camera.CFrame.p).Magnitude <= RenderDistance) or (Position - Camera.CFrame.p).Magnitude <= RenderDistance
if ShowEffects then
if Type == "Normal" then
MakeImpactFX(Hit, Position, Normal, Material, ...)
elseif Type == "Blood" then
MakeBloodFX(Hit, Position, Normal, Material, ...)
end
end
end
function ProjectileHandler:SimulateProjectile(Module, Tool, Handle, Directions, FirePointObject, HitEffectData, BloodEffectData, BulletHoleData, ExplosiveData, BulletData, WhizData, ClientData)
if Module and Tool and Handle then
if ClientData ~= nil then
VisualizeBullet:FireServer(Module, Tool, Handle, Directions, FirePointObject, HitEffectData, BloodEffectData, BulletHoleData, ExplosiveData, BulletData, WhizData, nil)
end
for _, Direction in pairs(Directions) do
local Origin, Dir = FirePointObject.WorldPosition, Direction
if FirePointObject ~= nil then
local TipCFrame = FirePointObject.WorldCFrame
local TipPos = TipCFrame.Position
local TipDir = TipCFrame.LookVector
local AmountToCheatBack = math.abs((Tool.Parent:FindFirstChild("HumanoidRootPart").Position - TipPos):Dot(TipDir)) + 1
local gunRay = Ray.new(TipPos - TipDir.Unit * AmountToCheatBack, TipDir.Unit * AmountToCheatBack)
local HitPart, HitPoint = Workspace:FindPartOnRayWithIgnoreList(gunRay, {Handle, Tool.Parent, Camera}, false, true)
if HitPart and math.abs((TipPos - HitPoint).Magnitude) > 0 then
Origin = HitPoint - TipDir.Unit * 0.1
--Dir = TipDir.Unit
end
end
local HumanoidRootPart = Tool.Parent:WaitForChild("HumanoidRootPart", 1)
local MyMovementSpeed = HumanoidRootPart.Velocity
local ModifiedBulletSpeed = (Dir * BulletData[2]) -- + MyMovementSpeed
local Bullet = Projectiles[BulletData[1]]:Clone()
Bullet.CFrame = CFrame.new(Origin, Origin + Dir)
Bullet.Parent = Camera
local Whizzed = Instance.new("BoolValue")
Whizzed.Name = "Whizzed"
Whizzed.Value = false
Whizzed.Parent = Bullet
for _, v in pairs(Bullet:GetDescendants()) do
if v:IsA("ParticleEmitter") then
v.Enabled = true
elseif v:IsA("Sound") then
v:Play()
elseif v:IsA("PointLight") then
v.Enabled = true
elseif v:IsA("Trail") then
v.Enabled = true
elseif v:IsA("Beam") then
v.Enabled = true
end
end
if ClientData ~= nil then
if (BulletData[10] > 0 or BulletData[11] > 0) and not ExplosiveData[1] then
Caster:FireWithBlacklist(Origin, Dir * BulletData[4], ModifiedBulletSpeed, {Handle, Tool.Parent, Camera}, Bullet, true, BulletData[3], {BulletData[6], BulletData[7], BulletData[8], BulletData[9]}, WhizData,
{{ExplosiveData[1], ExplosiveData[2], ExplosiveData[3], ExplosiveData[4], ExplosiveData[5], ExplosiveData[6], ExplosiveData[7], ExplosiveData[8], ExplosiveData[9], ExplosiveData[10], ExplosiveData[11], ExplosiveData[12], ExplosiveData[13], ExplosiveData[14], ExplosiveData[15], ExplosiveData[16], ExplosiveData[17], ExplosiveData[18], ExplosiveData[19], ExplosiveData[20], ExplosiveData[21], ExplosiveData[22], ExplosiveData[23]},
{HitEffectData[1], HitEffectData[2], HitEffectData[3], HitEffectData[4], HitEffectData[5], HitEffectData[6], HitEffectData[7], HitEffectData[8]},
{BulletHoleData[1], BulletHoleData[2], BulletHoleData[3], BulletHoleData[4], BulletHoleData[5], BulletHoleData[6]},
{BloodEffectData[1], BloodEffectData[2], BloodEffectData[3], BloodEffectData[4], BloodEffectData[5], BloodEffectData[6], BloodEffectData[7]},
Tool,
{{ClientData[1][1], ClientData[1][2], ClientData[1][3], ClientData[1][4], ClientData[1][5], ClientData[1][6], ClientData[1][7]},
{ClientData[2][1], ClientData[2][2], ClientData[2][3], ClientData[2][4], ClientData[2][5], ClientData[2][6], ClientData[2][7], ClientData[2][8]},
{ClientData[3][1], ClientData[3][2], ClientData[3][3]},
{ClientData[4][1], ClientData[4][2], ClientData[4][3], ClientData[4][4], ClientData[4][5], ClientData[4][6], ClientData[4][7]}},
Module},
{penetrationType = BulletData[5], penetrationDepth = BulletData[10], canPenetrateFunction = CanRayPenetrate, penetrationAmount = BulletData[11], canPenetrateHumanoidFunction = CanRayPenetrateHumanoid})
else
Caster:FireWithBlacklist(Origin, Dir * BulletData[4], ModifiedBulletSpeed, {Handle, Tool.Parent, Camera}, Bullet, true, BulletData[3], {BulletData[6], BulletData[7], BulletData[8], BulletData[9]}, WhizData,
{{ExplosiveData[1], ExplosiveData[2], ExplosiveData[3], ExplosiveData[4], ExplosiveData[5], ExplosiveData[6], ExplosiveData[7], ExplosiveData[8], ExplosiveData[9], ExplosiveData[10], ExplosiveData[11], ExplosiveData[12], ExplosiveData[13], ExplosiveData[14], ExplosiveData[15], ExplosiveData[16], ExplosiveData[17], ExplosiveData[18], ExplosiveData[19], ExplosiveData[20], ExplosiveData[21], ExplosiveData[22], ExplosiveData[23]},
{HitEffectData[1], HitEffectData[2], HitEffectData[3], HitEffectData[4], HitEffectData[5], HitEffectData[6], HitEffectData[7], HitEffectData[8]},
{BulletHoleData[1], BulletHoleData[2], BulletHoleData[3], BulletHoleData[4], BulletHoleData[5], BulletHoleData[6]},
{BloodEffectData[1], BloodEffectData[2], BloodEffectData[3], BloodEffectData[4], BloodEffectData[5], BloodEffectData[6], BloodEffectData[7]},
Tool,
{{ClientData[1][1], ClientData[1][2], ClientData[1][3], ClientData[1][4], ClientData[1][5], ClientData[1][6], ClientData[1][7]},
{ClientData[2][1], ClientData[2][2], ClientData[2][3], ClientData[2][4], ClientData[2][5], ClientData[2][6], ClientData[2][7], ClientData[2][8]},
{ClientData[3][1], ClientData[3][2], ClientData[3][3]},
{ClientData[4][1], ClientData[4][2], ClientData[4][3], ClientData[4][4], ClientData[4][5], ClientData[4][6], ClientData[4][7]}},
Module},
nil)
end
else
if (BulletData[10] > 0 or BulletData[11] > 0) and not ExplosiveData[1] then
Caster:FireWithBlacklist(Origin, Dir * BulletData[4], ModifiedBulletSpeed, {Handle, Tool.Parent, Camera}, Bullet, true, BulletData[3], {BulletData[6], BulletData[7], BulletData[8], BulletData[9]}, WhizData,
{{ExplosiveData[1], ExplosiveData[2], ExplosiveData[3], ExplosiveData[4], ExplosiveData[5], ExplosiveData[6], ExplosiveData[7], ExplosiveData[8], ExplosiveData[9], ExplosiveData[10], ExplosiveData[11], ExplosiveData[12], ExplosiveData[13], ExplosiveData[14], ExplosiveData[15], ExplosiveData[16], ExplosiveData[17], ExplosiveData[18], ExplosiveData[19], ExplosiveData[20], ExplosiveData[21], ExplosiveData[22], ExplosiveData[23]},
{HitEffectData[1], HitEffectData[2], HitEffectData[3], HitEffectData[4], HitEffectData[5], HitEffectData[6], HitEffectData[7], HitEffectData[8]},
{BulletHoleData[1], BulletHoleData[2], BulletHoleData[3], BulletHoleData[4], BulletHoleData[5], BulletHoleData[6]},
{BloodEffectData[1], BloodEffectData[2], BloodEffectData[3], BloodEffectData[4], BloodEffectData[5], BloodEffectData[6], BloodEffectData[7]},
Tool, nil, Module},
{penetrationType = BulletData[5], penetrationDepth = BulletData[10], canPenetrateFunction = CanRayPenetrate, penetrationAmount = BulletData[11], canPenetrateHumanoidFunction = CanRayPenetrateHumanoid})
else
Caster:FireWithBlacklist(Origin, Dir * BulletData[4], ModifiedBulletSpeed, {Handle, Tool.Parent, Camera}, Bullet, true, BulletData[3], {BulletData[6], BulletData[7], BulletData[8], BulletData[9]}, WhizData,
{{ExplosiveData[1], ExplosiveData[2], ExplosiveData[3], ExplosiveData[4], ExplosiveData[5], ExplosiveData[6], ExplosiveData[7], ExplosiveData[8], ExplosiveData[9], ExplosiveData[10], ExplosiveData[11], ExplosiveData[12], ExplosiveData[13], ExplosiveData[14], ExplosiveData[15], ExplosiveData[16], ExplosiveData[17], ExplosiveData[18], ExplosiveData[19], ExplosiveData[20], ExplosiveData[21], ExplosiveData[22], ExplosiveData[23]},
{HitEffectData[1], HitEffectData[2], HitEffectData[3], HitEffectData[4], HitEffectData[5], HitEffectData[6], HitEffectData[7], HitEffectData[8]},
{BulletHoleData[1], BulletHoleData[2], BulletHoleData[3], BulletHoleData[4], BulletHoleData[5], BulletHoleData[6]},
{BloodEffectData[1], BloodEffectData[2], BloodEffectData[3], BloodEffectData[4], BloodEffectData[5], BloodEffectData[6], BloodEffectData[7]},
Tool, nil, Module},
nil)
end
end
end
end
end
Caster.LengthChanged:Connect(OnRayUpdated)
Caster.RayHit:Connect(OnRayHit)
Caster.RayExited:Connect(OnRayExited)
return ProjectileHandler
|
-- Roblox services |
local PhysicsService = game:GetService("PhysicsService")
local Players = game:GetService("Players")
local npcModel = script.Parent
|
--DO NOT CHANGE ANYTHING INSIDE OF THIS SCRIPT BESIDES WHAT YOU ARE TOLD TO UNLESS YOU KNOW WHAT YOU'RE DOING OR THE SCRIPT WILL NOT WORK!! |
local hitPart = script.Parent
local debounce = true
local tool = game.ServerStorage.Slingshot |
-- if Plr.Backpack:FindFirstChild("Reactor Startup Key") then |
key=true
keyset:Fire() |
--[=[
Returns whether or not a value is an observable.
@param item any
@return boolean
]=] |
function Observable.isObservable(item)
return type(item) == "table" and item.ClassName == "Observable"
end
|
-- Mimic the enabling of the topbar when StarterGui:SetCore("TopbarEnabled", state) is called |
coroutine.wrap(function()
local chatScript = players.LocalPlayer.PlayerScripts:WaitForChild("ChatScript", 4) or game:GetService("Chat"):WaitForChild("ChatScript", 4)
if not chatScript then return end
local chatMain = chatScript:FindFirstChild("ChatMain")
if not chatMain then return end
local ChatMain = require(chatMain)
ChatMain.CoreGuiEnabled:connect(function()
local topbarEnabled = checkTopbarEnabled()
if topbarEnabled == IconController.previousTopbarEnabled then
IconController.updateTopbar()
return "SetCoreGuiEnabled was called instead of SetCore"
end
IconController.previousTopbarEnabled = topbarEnabled
if IconController.controllerModeEnabled then
IconController.setTopbarEnabled(false,false)
else
IconController.setTopbarEnabled(topbarEnabled,false)
end
IconController.updateTopbar()
end)
IconController.setTopbarEnabled(checkTopbarEnabled(),false)
end)()
|
-- Map storing Player -> Blocked user Ids. |
local BlockedUserIdsMap = {}
PlayersService.PlayerAdded:connect(function(newPlayer)
for player, blockedUsers in pairs(BlockedUserIdsMap) do
local speaker = ChatService:GetSpeaker(player.Name)
if speaker then
for i = 1, #blockedUsers do
local blockedUserId = blockedUsers[i]
if blockedUserId == newPlayer.UserId then
speaker:AddMutedSpeaker(newPlayer.Name)
end
end
end
end
end)
PlayersService.PlayerRemoving:connect(function(removingPlayer)
BlockedUserIdsMap[removingPlayer] = nil
end)
EventFolder.SetBlockedUserIdsRequest.OnServerEvent:connect(function(player, blockedUserIdsList)
if type(blockedUserIdsList) ~= "table" then
return
end
BlockedUserIdsMap[player] = blockedUserIdsList
local speaker = ChatService:GetSpeaker(player.Name)
if speaker then
for i = 1, #blockedUserIdsList do
if type(blockedUserIdsList[i]) == "number" then
local blockedPlayer = PlayersService:GetPlayerByUserId(blockedUserIdsList[i])
if blockedPlayer then
speaker:AddMutedSpeaker(blockedPlayer.Name)
end
end
end
end
end)
EventFolder.GetInitDataRequest.OnServerInvoke = (function(playerObj)
local speaker = ChatService:GetSpeaker(playerObj.Name)
if not (speaker and speaker:GetPlayer()) then
CreatePlayerSpeakerObject(playerObj)
speaker = ChatService:GetSpeaker(playerObj.Name)
end
local data = {}
data.Channels = {}
data.SpeakerExtraData = {}
for _, channelName in pairs(speaker:GetChannelList()) do
local channelObj = ChatService:GetChannel(channelName)
if (channelObj) then
local channelData =
{
channelName,
channelObj:GetWelcomeMessageForSpeaker(speaker),
channelObj:GetHistoryLogForSpeaker(speaker),
channelObj.ChannelNameColor,
}
table.insert(data.Channels, channelData)
end
end
for _, oSpeakerName in pairs(ChatService:GetSpeakerList()) do
local oSpeaker = ChatService:GetSpeaker(oSpeakerName)
data.SpeakerExtraData[oSpeakerName] = oSpeaker.ExtraData
end
return data
end)
local function DoJoinCommand(speakerName, channelName, fromChannelName)
local speaker = ChatService:GetSpeaker(speakerName)
local channel = ChatService:GetChannel(channelName)
if (speaker) then
if (channel) then
if (channel.Joinable) then
if (not speaker:IsInChannel(channel.Name)) then
speaker:JoinChannel(channel.Name)
else
speaker:SetMainChannel(channel.Name)
local msg = ChatLocalization:FormatMessageToSend(
"GameChat_SwitchChannel_NowInChannel",
string.format("You are now chatting in channel: '%s'", channel.Name),
"RBX_NAME",
channel.Name)
speaker:SendSystemMessage(msg, channel.Name)
end
else
local msg = ChatLocalization:FormatMessageToSend(
"GameChat_ChatServiceRunner_YouCannotJoinChannel",
"You cannot join channel '" .. channelName .. "'.",
"RBX_NAME",
channelName)
speaker:SendSystemMessage(msg, fromChannelName)
end
else
local msg = ChatLocalization:FormatMessageToSend(
"GameChat_ChatServiceRunner_ChannelDoesNotExist",
"Channel '" .. channelName .. "' does not exist.",
"RBX_NAME",
channelName)
speaker:SendSystemMessage(msg, fromChannelName)
end
end
end
local function DoLeaveCommand(speakerName, channelName, fromChannelName)
local speaker = ChatService:GetSpeaker(speakerName)
local channel = ChatService:GetChannel(channelName)
if (speaker) then
if (speaker:IsInChannel(channelName)) then
if (channel.Leavable) then
speaker:LeaveChannel(channel.Name)
local msg = ChatLocalization:FormatMessageToSend(
"GameChat_ChatService_YouHaveLeftChannel",
string.format("You have left channel '%s'", channelName),
"RBX_NAME",
channel.Name)
speaker:SendSystemMessage(msg, "System")
else
local msg = ChatLocalization:FormatMessageToSend(
"GameChat_ChatServiceRunner_YouCannotLeaveChannel",
("You cannot leave channel '" .. channelName .. "'."),
"RBX_NAME",
channelName)
speaker:SendSystemMessage(msg, fromChannelName)
end
else
local msg = ChatLocalization:FormatMessageToSend(
"GameChat_ChatServiceRunner_YouAreNotInChannel",
("You are not in channel '" .. channelName .. "'."),
"RBX_NAME",
channelName)
speaker:SendSystemMessage(msg, fromChannelName)
end
end
end
ChatService:RegisterProcessCommandsFunction("default_commands", function(fromSpeaker, message, channel)
if (string.sub(message, 1, 6):lower() == "/join ") then
DoJoinCommand(fromSpeaker, string.sub(message, 7), channel)
return true
elseif (string.sub(message, 1, 3):lower() == "/j ") then
DoJoinCommand(fromSpeaker, string.sub(message, 4), channel)
return true
elseif (string.sub(message, 1, 7):lower() == "/leave ") then
DoLeaveCommand(fromSpeaker, string.sub(message, 8), channel)
return true
elseif (string.sub(message, 1, 3):lower() == "/l ") then
DoLeaveCommand(fromSpeaker, string.sub(message, 4), channel)
return true
end
return false
end)
if ChatSettings.GeneralChannelName and ChatSettings.GeneralChannelName ~= "" then
local allChannel = ChatService:AddChannel(ChatSettings.GeneralChannelName)
allChannel.Leavable = false
allChannel.AutoJoin = true
allChannel:RegisterGetWelcomeMessageFunction(function(speaker)
if RunService:IsStudio() then
return nil
end
local player = speaker:GetPlayer()
if player then
local success, canChat = pcall(function()
return Chat:CanUserChatAsync(player.UserId)
end)
if success and not canChat then
return ""
end
end
end)
end
local systemChannel = ChatService:AddChannel("System")
systemChannel.Leavable = false
systemChannel.AutoJoin = true
systemChannel.WelcomeMessage = ChatLocalization:FormatMessageToSend(
"GameChat_ChatServiceRunner_SystemChannelWelcomeMessage", "This channel is for system and game notifications."
)
systemChannel.SpeakerJoined:connect(function(speakerName)
systemChannel:MuteSpeaker(speakerName)
end)
local function TryRunModule(module)
if module:IsA("ModuleScript") then
local ret = require(module)
if (type(ret) == "function") then
ret(ChatService)
end
end
end
local modules = Chat:WaitForChild("ChatModules")
modules.ChildAdded:connect(function(child)
local success, returnval = pcall(TryRunModule, child)
if not success and returnval then
print("Error running module " ..child.Name.. ": " ..returnval)
end
end)
for _, module in pairs(modules:GetChildren()) do
local success, returnval = pcall(TryRunModule, module)
if not success and returnval then
print("Error running module " ..module.Name.. ": " ..returnval)
end
end
PlayersService.PlayerRemoving:connect(function(playerObj)
if (ChatService:GetSpeaker(playerObj.Name)) then
ChatService:RemoveSpeaker(playerObj.Name)
end
end)
|
-- Critically damped spring class for fluid motion effects |
local Spring = {} do
Spring.__index = Spring
-- Initialize to a given undamped frequency and default position
function Spring.new(freq, pos)
return setmetatable({
freq = freq,
goal = pos,
pos = pos,
vel = 0,
}, Spring)
end
-- Advance the spring simulation by `dt` seconds
function Spring:step(dt)
local f = self.freq*2*math.pi
local g = self.goal
local p0 = self.pos
local v0 = self.vel
local offset = p0 - g
local decay = math.exp(-f*dt)
local p1 = (offset*(1 + f*dt) + v0*dt)*decay + g
local v1 = (v0*(1 - f*dt) - offset*(f*f*dt))*decay
self.pos = p1
self.vel = v1
return p1
end
end
CameraUtils.Spring = Spring
|
--local GameFolder = Workspace.Game:GetDescendants() |
local Gui = PlayerGui:WaitForChild("LoadingScreen")
Gui.Enabled = true
local erase = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
local Loaded = 0
local toLoad = #petModelFolder --+ #GameFolder
|
----------------------------------------------------------------------------------
-- Adonis Loader --
-- By Epix Incorporated --
----------------------------------------------------------------------------------
-- Edit settings using the Settings module in the Config folder --
----------------------------------------------------------------------------------
-- This script loads the Adonis source (MainModule) into the game. --
-- Only edit this script if you know what you're doing! --
---------------------------------------------------------------------------------- |
local warn = function(...)
warn(":: Adonis ::", ...)
end
warn("Loading...")
local ServerScriptService = game:GetService("ServerScriptService")
local RunService = game:GetService("RunService")
local mutex = RunService:FindFirstChild("__Adonis_MUTEX")
if mutex then
if mutex:IsA("StringValue") then
warn("Adonis is already running! Aborting...; Running Location:", mutex.Value, "This Location:", script:GetFullName())
else
warn("Adonis mutex detected but is not a StringValue! Aborting anyway...; This Location:", script:GetFullName())
end
else
mutex = Instance.new("StringValue")
mutex.Name = "__Adonis_MUTEX"
mutex.Archivable = false
mutex.Value = script:GetFullName()
mutex.Parent = RunService
local model = script.Parent.Parent
local configFolder = model.Config
local loaderFolder = model.Loader
local dropper = loaderFolder.Dropper
local loader = loaderFolder.Loader
local runner = script
local settingsModule = configFolder.Settings
local pluginsFolder = configFolder.Plugins
local themesFolder = configFolder.Themes
local backup = model:Clone()
local data = {
Settings = {} :: {[string]: any};
Descriptions = {} :: {[string]: string};
Messages = {} :: {string|{[string]: any}};
ServerPlugins = {} :: {ModuleScript};
ClientPlugins = {} :: {ModuleScript};
Packages = {} :: {Folder};
Themes = {} :: {Instance};
ModelParent = model.Parent;
Model = model;
Config = configFolder;
Core = loaderFolder;
Loader = loader;
Dopper = dropper;
Runner = runner;
ModuleID = 7510592873; --// https://www.roblox.com/library/7510592873/Adonis-MainModule
LoaderID = 7510622625; --// https://www.roblox.com/library/7510622625/Adonis-Loader-Sceleratis-Davey-Bones-Epix
--// Note: The nightly module is updated frequently with ever commit merged to the master branch on the Adonis repo.
--// It is prone to breaking, unstable, untested, and should not be used for anything other than testing/feature preview.
NightlyMode = false; --// If true, uses the nightly module instead of the current release module.
NightlyModuleID = 8612978896; --// https://www.roblox.com/library/8612978896/Nightlies-Adonis-MainModule
DebugMode = false;
}
--// Init
-- selene: allow(incorrect_standard_library_use)
script.Parent = nil --script:Destroy()
model.Name = math.random()
local moduleId = if data.NightlyMode then data.NightlyModuleID else data.ModuleID
if data.DebugMode then
for _, v in model.Parent:GetChildren() do
if v.Name == "MainModule" and v:IsA("ModuleScript") then
moduleId = v
break
end
end
if not moduleId then
error(`Adonis DebugMode is enabled but no ModuleScript named 'MainModule' is found in {model.Parent:GetFullName()}`)
end
end
local success, setTab = pcall(require, settingsModule)
if success then
data.Messages = setTab.Settings.Messages
else
warn("[DEVELOPER ERROR] Settings module errored while loading; Using defaults; Error Message: ", setTab)
table.insert(data.Messages, {
Title = "Warning!";
Icon = "rbxassetid://7495468117";
Message = "Settings module error detected; using default settings.";
Time = 15;
})
setTab = {}
end
data.Settings = setTab.Settings
data.Descriptions = setTab.Description
data.Order = setTab.Order
for _, module in pluginsFolder:GetChildren() do
local name = string.lower(module.Name)
if module:IsA("Folder") then
table.insert(data.Packages, module)
elseif string.match(name, "^client[%-:]") then
table.insert(data.ClientPlugins, module)
elseif string.match(name, "^server[%-:]") then
table.insert(data.ServerPlugins, module)
else
warn(`[DEVELOPER ERROR] Unknown Plugin Type for {module}; Plugin name should either start with 'Server:', 'Server-', 'Client:', or 'Client-'`)
end
end
for _, theme in themesFolder:GetChildren() do
table.insert(data.Themes, theme)
end
if tonumber(moduleId) then
warn(`Requiring Adonis MainModule; Model URL: https://www.roblox.com/library/{moduleId}`)
end
local module = require(moduleId)
local response = module(data)
if response == "SUCCESS" then
if (data.Settings and data.Settings.HideScript) and not data.DebugMode and not RunService:IsStudio() then
model.Parent = nil
game:BindToClose(function()
model.Parent = ServerScriptService
model.Name = "Adonis_Loader"
end)
end
model.Name = "Adonis_Loader"
else
error(" !! Adonis MainModule failed to load !! ")
end
end
--[[
--___________________________________________________________________________________________--
--___________________________________________________________________________________________--
--___________________________________________________________________________________________--
--___________________________________________________________________________________________--
___________ .__ .___
\_ _____/_____ |__|__ ___ | | ____ ____
| __)_\____ \| \ \/ / | |/ \_/ ___\
| \ |_> > |> < | | | \ \___
/_______ / __/|__/__/\_ \ |___|___| /\___ > /\
\/|__| \/ \/ \/ \/
--------------------------------------------------------
Epix Incorporated. Not Everything is so Black and White.
--------------------------------------------------------
--___________________________________________________________________________________________--
--___________________________________________________________________________________________--
--___________________________________________________________________________________________--
--___________________________________________________________________________________________--
--]]
|
--- Same as indexing, but uses an incremented number as a key.
-- @param task An item to clean
-- @treturn number taskId |
function Maid:giveTask(task)
if not task then
error("Task cannot be false or nil", 2)
end
local taskId = #self._tasks+1
self[taskId] = task
if type(task) == "table" and (not (task.Destroy or task.destroy)) then
warn("[Maid.GiveTask] - Gave table task without .Destroy\n\n" .. debug.traceback())
end
return taskId
end
|
-- functions |
function onRunning(speed)
if speed>0 then
pose = "Running"
else
pose = "Standing"
end
end
function onDied()
pose = "Dead"
end
function onJumping()
pose = "Jumping"
end
function onClimbing()
pose = "Climbing"
end
function onGettingUp()
pose = "GettingUp"
end
function onFreeFall()
pose = "FreeFall"
end
function onFallingDown()
pose = "FallingDown"
end
function onSeated()
pose = "Seated"
end
function onPlatformStanding()
pose = "PlatformStanding"
end
function moveJump()
RightShoulder.MaxVelocity = 0.5
LeftShoulder.MaxVelocity = 0.5
RightShoulder:SetDesiredAngle(3.14)
LeftShoulder:SetDesiredAngle(-3.14)
RightHip:SetDesiredAngle(0)
LeftHip:SetDesiredAngle(0)
end
|
-- Example: Connect buttons to the castVote function |
local button1 = script.Parent.MapFrame.VoteButton
local button2 = script.Parent.MapFrame1.VoteButton
button1.MouseButton1Click:Connect(function()
castVote("Dead Town")
end)
button2.MouseButton1Click:Connect(function()
castVote("Test Map")
end)
|
--Globals |
local AI = script.Parent
local AIName = AI.Name
local AItorso = AI.Torso
if true then -- if your torso doesn't have a Humanoid; flip this to false
local HumanoidType = nil -- find-a-HumanoidObject -- make sure
local list = AI:GetChildren() -- temp var.
for x = 1, #list do
local temp = list[x]
if (temp.className == "Humanoid") then
HumanoidType = temp.Name
end -- found Humanoid
end -- AI Parts
if HumanoidType then
number = math.floor(number*100) -- serial# of AI
hum = AI[HumanoidType]
BRAINWave = 7/hum.WalkSpeed -- For extreme speeds, this may have to be adjusted.
print (script, ": Humanoid = ", hum, AI:GetFullName(), number, "- Think Speed = ", BRAINWave)
end
end -- set speed
|
--The main script, this regulates basic values of the local elements |
local Steamer = script.Parent.Parent.Content.Steam
local Eaten = script.Parent.Parent.Content
local SoundA = script.Parent.Slurp
local WarmSoup = script.Parent.TastySoup
local Clickable = script.Parent.ClickDetector
function SoupEaten()
Clickable.MaxActivationDistance = 0 -- Fake debounce, but better than normal - less laggy
SoundA:Play()
Steamer.Enabled = false
Eaten.Transparency = 1
WarmSoup.Disabled = true
wait(50)
Eaten.Transparency = 0
WarmSoup.Disabled = false
Clickable.MaxActivationDistance = 15
Steamer.Enabled = true
end
script.Parent.ClickDetector.MouseClick:connect(SoupEaten) |
--<DON'T TOUCH THE SCRIPT UNLESS YOU KNOW WHAT YOU ARE DOING! |
local RS = game:GetService('ReplicatedStorage')
local TS = game:GetService('TweenService')
local Tool = script.Parent
local TextureArray = {}
local Activated = false
local Debounce = false
local Cooldown = 1
local Prop = nil
local LaughAnim = nil
Tool.Activated:Connect(function()
if not Debounce then
Debounce = true
task.delay(Cooldown, function()
Debounce = false
end)
local Character = Tool.Parent
if not Activated then
Activated = true
LaughAnim = Character.Humanoid:LoadAnimation(RS.GhoulV4.Laugh)
LaughAnim:Play()
Character.HumanoidRootPart.Anchored = true
Prop = RS.GhoulV4.Props.Wings:Clone()
Prop.Parent = Character
local Attachment = Instance.new('Attachment')
Attachment.Parent = Character.HumanoidRootPart
Attachment.Position = Vector3.new(0,-2.5,0)
local Wave = RS.GhoulV4.Effects.Wave:Clone()
Wave.Parent = Attachment
local Smoke = RS.GhoulV4.Effects.Smoke:Clone()
Smoke.Parent = Character.HumanoidRootPart
local Pixel = RS.GhoulV4.Effects.Pixel:Clone()
Pixel.Parent = Character.HumanoidRootPart
local Laugh = RS.GhoulV4.Sound.Laugh:Clone()
Laugh.Parent = Character.HumanoidRootPart
local SmokeSound = RS.GhoulV4.Sound.Smoke:Clone()
SmokeSound.Parent = Character.HumanoidRootPart
Laugh:Play()
task.delay(1.6,function()
Laugh:Destroy()
task.wait(0.25)
Character.HumanoidRootPart.Anchored = false
LaughAnim:Stop()
end)
SmokeSound:Play()
local Tween = TS:Create(SmokeSound, TweenInfo.new(1.5), {Volume = 0})
Tween:Play()
Tween.Completed:Connect(function()
SmokeSound:Destroy()
end)
Wave:Emit(2)
Smoke:Emit(100)
Pixel:Emit(50)
for _, Item in ipairs(Character.Humanoid:GetAccessories()) do
local Hair = Item.Handle:FindFirstChild("HairAttachment") ~= nil
if Hair then
TextureArray[Item] = {TextureID = Item.Handle.TextureID, Color = Item.Handle.Color, Material = Item.Handle.Material}
Item.Handle.Color = Color3.fromRGB(255, 0, 0)
Item.Handle.TextureID = ''
Item.Handle.Material = Enum.Material.Neon
end
end
elseif Activated then
Activated = false
local Tween = TS:Create(Prop.Handle, TweenInfo.new(0.5), {Transparency = 1})
Tween:Play()
Tween.Completed:Connect(function()
Prop:Destroy()
end)
for _, Item in ipairs(Character.Humanoid:GetAccessories()) do
local Hair = Item.Handle:FindFirstChild("HairAttachment") ~= nil
if Hair then
Item.Handle.Color = TextureArray[Item].Color
Item.Handle.Material = TextureArray[Item].Material
Item.Handle.TextureID = TextureArray[Item].TextureID
TextureArray[Item] = nil
end
end
end
end
end)
|
--[[
Cleans up the tasks passed in as the arguments.
A task can be any of the following:
- an Instance - will be destroyed
- an RBXScriptConnection - will be disconnected
- a function - will be run
- a table with a `Destroy` or `destroy` function - will be called
- an array - `cleanup` will be called on each item
]] |
local function cleanupOne(task: any)
local taskType = typeof(task)
-- case 1: Instance
if taskType == "Instance" then
task:Destroy()
-- case 2: RBXScriptConnection
elseif taskType == "RBXScriptConnection" then
task:Disconnect()
-- case 3: callback
elseif taskType == "function" then
task()
elseif taskType == "table" then
-- case 4: destroy() function
if typeof(task.destroy) == "function" then
task:destroy()
-- case 5: Destroy() function
elseif typeof(task.Destroy) == "function" then
task:Destroy()
-- case 6: array of tasks
elseif task[1] ~= nil then
for _, subtask in ipairs(task) do
cleanupOne(subtask)
end
end
end
end
local function cleanup(...: any)
for index = 1, select("#", ...) do
cleanupOne(select(index, ...))
end
end
return cleanup
|
-- upstream: https://github.com/facebook/react/blob/75955bf1d7ff6c2c1f4052f4a84dd2ce6944c62e/packages/shared/formatProdErrorMessage.js
--!strict
--[[*
* 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.
*
]] | |
--Zombie artificial stupidity script |
sp=script.Parent
lastattack=0
nextrandom=0
nextsound=0
nextjump=0
chasing=false
variance=4
damage=10
attackrange=4.5
sightrange=999--60
runspeed=16
wonderspeed=8
healthregen=false
colors={"Sand red","Dusty Rose","Medium blue","Sand blue","Lavender","Earth green","Brown","Medium stone grey","Brick yellow"}
function raycast(spos,vec,currentdist)
local hit2,pos2=game.Workspace:FindPartOnRay(Ray.new(spos+(vec*.01),vec*currentdist),script.Parent)
if hit2~=nil and pos2 then
if hit2.Parent==script.Parent and hit2.Transparency>=.8 or hit2.Name=="Handle" or string.sub(hit2.Name,1,6)=="Effect" or hit2.Parent:IsA("Hat") or hit2.Parent:IsA("Tool") or (hit2.Parent:FindFirstChild("Humanoid") and hit2.Parent:FindFirstChild("TEAM") and hit2.Parent:FindFirstChild("TEAM").Value == script.Parent.TEAM.Value) or (not hit2.Parent:FindFirstChild("Humanoid") and hit2.CanCollide==false) then
local currentdist=currentdist-(pos2-spos).magnitude
return raycast(pos2,vec,currentdist)
end
end
return hit2,pos2
end
function waitForChild(parent,childName)
local child=parent:findFirstChild(childName)
if child then return child end
while true do
child=parent.ChildAdded:wait()
if child.Name==childName then return child end
end
end
|
--Adding additional ignorePurchases because of the unlockPurchases setting that each button
--has dependancies |
local unlock = {}
local allButtons = tycoons[1].Buttons:GetChildren()
local unlockPurchases = RebirthSettings.unlockPurchases
function addDependencies(ignoreInner,obj)
local queue = {}
for t = 1,#allButtons,1 do
local object = allButtons[t]:FindFirstChild("Object")
local dependency = allButtons[t]:FindFirstChild("Dependency")
if object ~= nil and dependency ~= nil then
if dependency.Value == obj then
table.insert(ignoreInner,object.Value)
table.insert(queue,object.Value)
end
end
end
for d = 1,#queue,1 do
addDependencies(ignoreInner,queue[d])
end
end
for u = 1,#unlockPurchases,1 do
unlock[u] = {rebirthCount = unlockPurchases[u].rebirthCount}
table.insert(unlock[u],unlockPurchases[u].unlock)
addDependencies(unlock[u],unlockPurchases[u].unlock)
end
function hideBillboadAndText(billboardGui, textLabel)
if billboardGui then
billboardGui.Enabled = false
if textLabel then
textLabel.TextTransparency = 1
end
end
end
function showBillboadAndText(billboardGui, textLabel)
if billboardGui then
billboardGui.Enabled = true
if textLabel then
textLabel.TextTransparency = 0
end
end
end
function hideButton(name,buttons)
local allButtons = buttons:GetChildren()
local item = nil
for i = 1,#allButtons,1 do
local hasObject = allButtons[i]:FindFirstChild("Object")
if hasObject and hasObject:IsA("StringValue") and
allButtons[i].Object.Value == name then
item = allButtons[i]
break
end
end
if item ~= nil then
local head = item:FindFirstChild("Head")
if head ~= nil then
local billboardGui = head:FindFirstChild("BillboardGui")
local textLabel
if billboardGui then
textLabel = billboardGui:FindFirstChild("TextLabel")
end
if TycoonSettings['ButtonsFadeOut'] then
head.CanCollide = false
coroutine.resume(coroutine.create(function()
for i=1,20 do
wait(TycoonSettings['FadeOutTime']/20)
head.Transparency = head.Transparency + 0.05
if textLabel then
textLabel.TextTransparency = textLabel.TextTransparency + 0.05
end
end
hideBillboadAndText(billboardGui, textLabel)
end))
else
head.CanCollide = false
head.Transparency = 1
hideBillboadAndText(billboardGui, textLabel)
end
end
end
end
local function getTouchToClaimAndDeleteGateControl(nextTycoon)
local gate = nextTycoon.Entrance:GetChildren()
local touchToClaim = nil
for i = 1,#gate, 1 do
local gateControl = gate[i]:FindFirstChild("GateControl")
if gateControl ~= nil then
touchToClaim = gate[i]
gateControl:Destroy()
break
end
end
if touchToClaim == nil then
error("Zed's tycoon Save scripts make sure you have a script called 'GateControl' in each tycoons Entrance/Touch to claim!")
end
return touchToClaim
end
function loadPurchedObjectFromDatabaseIfPlayerTouchToClaim(touchToClaimHead,
purchasedObjects,
PurchaseHandlerNew,
tycoon)
--TODO all purhcases must have a button
local purchases = tycoon:WaitForChild("Purchases")
while true do
wait(0.1)
if #purchases:GetChildren() < 10 then break end
end
local debounce = true
touchToClaimHead.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid ~= nil and humanoid.Health > 0 and debounce then
local success,err = pcall(function()
local playerInPlayerMoney = playerMoney:FindFirstChild(humanoid.Parent.Name)
local ownsTycoon = nil
if playerInPlayerMoney ~= nil then
ownsTycoon = playerInPlayerMoney:FindFirstChild("OwnsTycoon")
end
if ownsTycoon ~= nil and ownsTycoon.Value == nil and not tycoon.Owner.Value then
local player = game.Players:FindFirstChild(humanoid.Parent.Name)
print("Before loading objects in tycoon for player ",player.Name)
print("------------------------------")
if player ~= nil then
debounce = false
tycoon.CurrencyToCollect.Value = 0
touchToClaimHead.Transparency = 1
tycoon.Owner.Value = player
ownsTycoon.Value = tycoon
touchToClaimHead.Parent.Name = player.Name.."'s Tycoon"
touchToClaimHead.Transparency = 0.6
touchToClaimHead.CanCollide = false
player.TeamColor = tycoon.TeamColor.Value
local data = PlayerStatManager:getPlayerData(player)["TycoonPurchases"]
for key,value in pairs(PurchaseHandlerNew) do
print("Adding ",key)
if data[key] == true then
value.Parent = purchasedObjects
end
end
wait(2.5)
for k,v in pairs(PurchaseHandlerNew) do
if data[k] == true then
local buttonName = k
local buttons = tycoon.Buttons
hideButton(buttonName,buttons)
end
end
if RebirthSettings.enabled == true then
giveRebirthGuiIfTycoonFinished(PurchaseHandlerNew,player)
end
else
print(" loadPurchedObjectFromDatabaseIfPlayerTouchToClaim Player == nil")
end
else
print("ownsTycoon.Value ~= nil or ownsTycoon == nil ")
end
end)
if success == false then
print(err)
end
end
end)
end
function isTycoonFinished(PurchaseHandlerNew,player)
local purchases = PlayerStatManager:getPlayerData(player)["TycoonPurchases"]
local rebirthCountStat = PlayerStatManager:getStat(player,"RebirthCount")
local playerHasTycoonObject = false
--Checking what object should be ignored
for key1,value1 in pairs(PurchaseHandlerNew) do
local ignorePurchases = RebirthSettings.ignorePurchases
local canContinue = true
for i = 1,#ignorePurchases,1 do
if ignorePurchases[i] == key1 then
canContinue = false
break
end
end
--Check if it should ignore unlock purchases
for u = 1,#unlock,1 do
if rebirthCountStat < unlock[u].rebirthCount then
for a = 1,#unlock[u],1 do
if unlock[u][a] == key1 then
canContinue = false
break
end
end
end
if canContinue == false then
break
end
end
if canContinue then
playerHasTycoonObject = false
for key2,value2 in pairs(purchases) do
if value2 == true and key1 == key2 then
playerHasTycoonObject = true
break
end
end
if playerHasTycoonObject == false then
return false
end
end
end
return true
end
function giveRebirthGuiIfTycoonFinished(PurchaseHandlerNew,player)
local hasFinishedTycoon = isTycoonFinished(PurchaseHandlerNew,player)
if hasFinishedTycoon == true then
local canRebirth = player:FindFirstChild("CanRebirth")
if canRebirth ~= nil then
canRebirth.Value = true
end
giveRebirthGui(player)
end
end
function giveRebirthGui(player)
local success,err = pcall(function()
local rebirthGuiClone = rebirthGui:Clone()
local playerGui = player:FindFirstChild("PlayerGui")
if playerGui ~= nil then
--Added wait because after player died and their character is added
--the gui does not get cloned only after I add wait
wait(3)
local hasRebirthGui = playerGui:FindFirstChild("RebirthGui (Don't Move)")
if hasRebirthGui == nil then
rebirthGuiClone.Parent = playerGui
end
else
print("playerGui == nil")
end
end)
if success == false then
print(err)
end
end
function savePurchasesObjectsInDatabase(owner,instance,PurchaseHandlerNew)
local status,err = pcall(function()
local player = owner.Value
if player ~= nil then
--local stat = PlayerStatManager:getStat(player,instance.Name)
local stat = PlayerStatManager:getStatInTycoonPurchases(player,instance.Name)
local statMoney = PlayerStatManager:getStat(player,"Money")
if player ~= nil and not stat then
PlayerStatManager:ChangeStatInTycoonPurchases(player, instance.Name, true)
if RebirthSettings.enabled == true then
giveRebirthGuiIfTycoonFinished(PurchaseHandlerNew,player)
end
end
end
end)
if status == false then
print(err)
end
end
function playerJoinedCallFunction(player)
local rebirthCountStat = PlayerStatManager:getStat(player,"RebirthCount")
local plrJoinedOrDied = RebirthSettings.playerRespawned
for i = 1,#plrJoinedOrDied,1 do
if rebirthCountStat and rebirthCountStat >= plrJoinedOrDied[i].rebirthCount then
plrJoinedOrDied[i][1](player)
end
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
if RebirthSettings.enabled == true then
local canRebirth = player:FindFirstChild("CanRebirth")
if canRebirth and canRebirth.Value == true then
giveRebirthGui(player)
end
playerJoinedCallFunction(player)
end
end)
end)
for i = 1,#tycoons,1 do
--getTouchToClaimAndDeleteGateControl also destroys the gate
local touchToClaim = getTouchToClaimAndDeleteGateControl(tycoons[i])
purchaseHandlerNew:Clone().Parent = tycoons[i]
local purchasedObjects = tycoons[i]:FindFirstChild("PurchasedObjects")
local owner = tycoons[i]:FindFirstChild("Owner")
local entrance = tycoons[i].Entrance
local touchToClaimHead = touchToClaim.Head
--Is PurchaseHandlerNew
allObjects[i] = require(tycoons[i].PurchaseHandlerNew)
--Load data
--Check old code below long load data
loadPurchedObjectFromDatabaseIfPlayerTouchToClaim(touchToClaimHead,
purchasedObjects,
allObjects[i],
tycoons[i])
--Save data
if purchasedObjects ~= nil and owner ~= nil then
purchasedObjects.ChildAdded:Connect(function(instance)
--Check old code below long save data
savePurchasesObjectsInDatabase(owner,instance,allObjects[i])
end)
else
error("SaveTrigger script won't save data because either purchasedObjects or owner is NIL")
end
end
tycoonsFolder.ChildAdded:Connect(function(tycoon)
purchaseHandlerNew:Clone().Parent = tycoon
local purchasedObjects = tycoon:FindFirstChild("PurchasedObjects")
local owner = tycoon:FindFirstChild("Owner")
local touchToClaim = getTouchToClaimAndDeleteGateControl(tycoon)
local touchToClaimHead = touchToClaim.Head
local PurchaseHandlerNew = require(tycoon.PurchaseHandlerNew)
--Load data
--Check old code below long load data
loadPurchedObjectFromDatabaseIfPlayerTouchToClaim(touchToClaimHead,
purchasedObjects,
PurchaseHandlerNew,
tycoon)
--Save data
if purchasedObjects ~= nil and owner ~= nil then
purchasedObjects.ChildAdded:Connect(function(instance)
--Check old code below long save data
savePurchasesObjectsInDatabase(owner,instance,PurchaseHandlerNew)
end)
else
error("SaveTrigger script won't save data because either purchasedObjects or owner is NIL")
end
end)
function getTycoonByPlayerName(playerName)
local allTycoons = tycoonsFolder:GetChildren()
for i = 1,#allTycoons,1 do
local owner = allTycoons[i]:FindFirstChild("Owner")
if owner ~= nil and allTycoons[i]:IsA("Model") then
if owner.Value ~= nil and owner.Value.Name == playerName then
return allTycoons[i]
end
else
print("MAKE SURE EACH TYCOON HAS OWNER VALUE")
end
end
return nil
end
function removeTycoonAndAddOriginal(tycoon,playerName)
local plrStats = game.ServerStorage.PlayerMoney:FindFirstChild(playerName)
if plrStats ~= nil then
plrStats.OwnsTycoon.Value = nil
end
if tycoon then
--Holds the original tycoons
local backup = AllTycoons[tycoon.Name]:Clone()
tycoon:Destroy()
wait()
local currencyToCollect = backup:FindFirstChild("CurrencyToCollect")
if currencyToCollect ~= nil then
currencyToCollect.Value = 0
else
print("currencyToCollect == nil ----------------------->")
end
backup.Parent=script.Parent.Tycoons
end
end
function teleportCharacterToSuppliedPart(player,tycoon)
local partName = RebirthSettings.teleportToo
local part = tycoon:FindFirstChild(partName)
if part and part:IsA("BasePart") then
local character = player.Character
if character then
character:SetPrimaryPartCFrame(part.CFrame)
end
end
end
function callFunctionsIfRebirthIsReached(rebirthCountStat,player)
local playerReachedRebirthCount = RebirthSettings.playerReachedRebirthCount
for i = 1,#playerReachedRebirthCount do
if playerReachedRebirthCount[i].rebirthCount == rebirthCountStat then
playerReachedRebirthCount[i][1](player)
break
end
end
end
local function getCashAmountByRebirthCount(array,rebirthCount)
for key,value in pairs(array) do
if value.rebirthCount == rebirthCount then
return value.cashAmount
end
end
end
rebirthEvent.OnServerEvent:Connect(function(player)
local rebirthCountStat = PlayerStatManager:getStat(player,"RebirthCount")
--TODO real investigate if rebirth count can be nil
if rebirthCountStat == nil then return end
local array = RebirthSettings.cashNeededForRebirth
local cashNeeded = getCashAmountByRebirthCount(array,rebirthCountStat+1)
local playerStats = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
if not cashNeeded then cashNeeded = RebirthSettings.defaultCashNeededForRebirth end
if RebirthSettings.enabled == true then
if (playerStats.Value >= cashNeeded) == false then
rebirthEvent:FireClient(player,cashNeeded)
return
end
local success,err = pcall(function()
local ownsTycoon = playerStats:FindFirstChild("OwnsTycoon")
if ownsTycoon ~= nil and ownsTycoon.Value ~= nil then
local tycoon = getTycoonByPlayerName(player.Name);
if tycoon ~= nil then
local PurchaseHandlerNew = require(tycoon.PurchaseHandlerNew)
local hasFinishedTycoon = isTycoonFinished(PurchaseHandlerNew,player)
if hasFinishedTycoon == true then
PlayerStatManager:setAllTycoonPurchasesToNil(player)
if rebirthCountStat == nil then
PlayerStatManager:saveStat(player,"RebirthCount",0)
end
if RebirthSettings.resetCash then
PlayerStatManager:saveStat(player,"Money",0)
end
PlayerStatManager:IncrementStat(player,"RebirthCount",1)
rebirthCountStat = PlayerStatManager:getStat(player,"RebirthCount")
for u = 1,#unlockPurchases,1 do
if rebirthCountStat >= unlockPurchases[u].rebirthCount then
--TODO check if there is bugs
PlayerStatManager:ChangeStatInTycoonPurchases(player, unlockPurchases[u].unlock, true)
end
end
callFunctionsIfRebirthIsReached(rebirthCountStat,player)
local leaderstats = player:FindFirstChild("leaderstats")
if leaderstats ~= nil then
local rebirths = leaderstats:FindFirstChild("Rebirths")
local moneyStat = leaderstats:FindFirstChild("Money")
if rebirths ~= nil and rebirthCountStat ~= nil then
rebirths.Value = rebirthCountStat
end
if moneyStat ~= nil and RebirthSettings.resetCash then
moneyStat.Value = 0
end
end
local playerStats = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
if RebirthSettings.resetCash then
playerStats.Value = 0
end
teleportCharacterToSuppliedPart(player,tycoon)
removeTycoonAndAddOriginal(tycoon,player.Name)
local canRebirth = player:FindFirstChild("CanRebirth")
if canRebirth ~= nil then
canRebirth.Value = false
end
local playerGui = player:FindFirstChild("PlayerGui")
if playerGui ~= nil then
local rebirthGui = playerGui:FindFirstChild("RebirthGui (Don't Move)")
if rebirthGui ~= nil then
rebirthGui:Destroy()
end
end
end
else
print("Tycoon is nil getTycoonByPlayerName("..player.Name..")")
end
end
end)
if success == false then
print(err)
end
end
end)
if runService:IsStudio() or TestSettings.showTouchTycoonButtonsGuiOutsideStudio then
local canContinueTouchingButtons = false
touchAllTycoonButtons.OnServerEvent:Connect(function(player,start)
canContinueTouchingButtons = start
if canContinueTouchingButtons then
local character = player.Character
local tycoon = getTycoonByPlayerName(player.Name);
if not tycoon then return end
while canContinueTouchingButtons do
local allTheButtons = tycoon.Buttons:GetChildren();
local notOpen = false
for i = 1,#allTheButtons,1 do
local head = allTheButtons[i]:FindFirstChild("Head")
if not canContinueTouchingButtons then return end
if head and head.Transparency == 0 then
local headPos = head.Position
local newPos = Vector3.new(headPos.X,headPos.Y+1.2,headPos.Z)
character:MoveTo(newPos)
wait(0.5)
notOpen = true
end
end
if notOpen == false then
break
end
end
end
end)
giveCashEvent.OnServerEvent:Connect(function(player,cashAmount)
local plrCash = playerMoney:FindFirstChild(player.Name)
if plrCash then
plrCash.Value = plrCash.Value + cashAmount
end
end)
end
|
-- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote |
local emoteNames = { wave = false, point = false, dance = true, laugh = false, cheer = false}
|
--////////////////////////////// Methods
--////////////////////////////////////// |
local methods = {}
methods.__index = methods
local function CreateGuiObjects()
local BaseFrame = Instance.new("Frame")
BaseFrame.Selectable = false
BaseFrame.Size = UDim2.new(1, 0, 1, 0)
BaseFrame.BackgroundTransparency = 1
local Scroller = Instance.new("ScrollingFrame")
Scroller.Selectable = ChatSettings.GamepadNavigationEnabled
Scroller.Name = "Scroller"
Scroller.BackgroundTransparency = 1
Scroller.BorderSizePixel = 0
Scroller.Position = UDim2.new(0, 0, 0, 3)
Scroller.Size = UDim2.new(1, -4, 1, -6)
Scroller.CanvasSize = UDim2.new(0, 0, 0, 0)
Scroller.ScrollBarThickness = module.ScrollBarThickness
Scroller.Active = FFlagUserChatHistorySinksInput
Scroller.Parent = BaseFrame
local Layout = Instance.new("UIListLayout")
Layout.SortOrder = Enum.SortOrder.LayoutOrder
Layout.Parent = Scroller
return BaseFrame, Scroller, Layout
end
function methods:Destroy()
self.GuiObject:Destroy()
self.Destroyed = true
end
function methods:SetActive(active)
self.GuiObject.Visible = active
end
function methods:UpdateMessageFiltered(messageData)
local messageObject = nil
local searchIndex = 1
local searchTable = self.MessageObjectLog
while (#searchTable >= searchIndex) do
local obj = searchTable[searchIndex]
if obj.ID == messageData.ID then
messageObject = obj
break
end
searchIndex = searchIndex + 1
end
if messageObject then
messageObject.UpdateTextFunction(messageData)
self:PositionMessageLabelInWindow(messageObject, searchIndex)
end
end
function methods:AddMessage(messageData)
self:WaitUntilParentedCorrectly()
local messageObject = MessageLabelCreator:CreateMessageLabel(messageData, self.CurrentChannelName)
if messageObject == nil then
return
end
table.insert(self.MessageObjectLog, messageObject)
self:PositionMessageLabelInWindow(messageObject, #self.MessageObjectLog)
end
function methods:AddMessageAtIndex(messageData, index)
local messageObject = MessageLabelCreator:CreateMessageLabel(messageData, self.CurrentChannelName)
if messageObject == nil then
return
end
table.insert(self.MessageObjectLog, index, messageObject)
self:PositionMessageLabelInWindow(messageObject, index)
end
function methods:RemoveLastMessage()
self:WaitUntilParentedCorrectly()
local lastMessage = self.MessageObjectLog[1]
lastMessage:Destroy()
table.remove(self.MessageObjectLog, 1)
end
function methods:IsScrolledDown()
local yCanvasSize = self.Scroller.CanvasSize.Y.Offset
local yContainerSize = self.Scroller.AbsoluteWindowSize.Y
local yScrolledPosition = self.Scroller.CanvasPosition.Y
return (yCanvasSize < yContainerSize or
yCanvasSize - yScrolledPosition <= yContainerSize + 5)
end
function methods:UpdateMessageTextHeight(messageObject)
local baseFrame = messageObject.BaseFrame
for i = 1, 10 do
if messageObject.BaseMessage.TextFits then
break
end
local trySize = self.Scroller.AbsoluteSize.X - i
baseFrame.Size = UDim2.new(1, 0, 0, messageObject.GetHeightFunction(trySize))
end
end
function methods:PositionMessageLabelInWindow(messageObject, index)
self:WaitUntilParentedCorrectly()
local wasScrolledDown = self:IsScrolledDown()
local baseFrame = messageObject.BaseFrame
local layoutOrder = 1
if self.MessageObjectLog[index - 1] then
if index == #self.MessageObjectLog then
layoutOrder = self.MessageObjectLog[index - 1].BaseFrame.LayoutOrder + 1
else
layoutOrder = self.MessageObjectLog[index - 1].BaseFrame.LayoutOrder
end
end
baseFrame.LayoutOrder = layoutOrder
baseFrame.Size = UDim2.new(1, 0, 0, messageObject.GetHeightFunction(self.Scroller.AbsoluteSize.X))
baseFrame.Parent = self.Scroller
if messageObject.BaseMessage then
self:UpdateMessageTextHeight(messageObject)
end
if wasScrolledDown then
self.Scroller.CanvasPosition = Vector2.new(
0, math.max(0, self.Scroller.CanvasSize.Y.Offset - self.Scroller.AbsoluteSize.Y))
end
end
function methods:ReorderAllMessages()
self:WaitUntilParentedCorrectly()
--// Reordering / reparenting with a size less than 1 causes weird glitches to happen
-- with scrolling as repositioning happens.
if self.GuiObject.AbsoluteSize.Y < 1 then return end
local oldCanvasPositon = self.Scroller.CanvasPosition
local wasScrolledDown = self:IsScrolledDown()
for _, messageObject in pairs(self.MessageObjectLog) do
self:UpdateMessageTextHeight(messageObject)
end
if not wasScrolledDown then
self.Scroller.CanvasPosition = oldCanvasPositon
else
self.Scroller.CanvasPosition = Vector2.new(
0, math.max(0, self.Scroller.CanvasSize.Y.Offset - self.Scroller.AbsoluteSize.Y))
end
end
function methods:Clear()
for _, v in pairs(self.MessageObjectLog) do
v:Destroy()
end
self.MessageObjectLog = {}
end
function methods:SetCurrentChannelName(name)
self.CurrentChannelName = name
end
function methods:FadeOutBackground(duration)
--// Do nothing
end
function methods:FadeInBackground(duration)
--// Do nothing
end
function methods:FadeOutText(duration)
for i = 1, #self.MessageObjectLog do
if self.MessageObjectLog[i].FadeOutFunction then
self.MessageObjectLog[i].FadeOutFunction(duration, CurveUtil)
end
end
end
function methods:FadeInText(duration)
for i = 1, #self.MessageObjectLog do
if self.MessageObjectLog[i].FadeInFunction then
self.MessageObjectLog[i].FadeInFunction(duration, CurveUtil)
end
end
end
function methods:Update(dtScale)
for i = 1, #self.MessageObjectLog do
if self.MessageObjectLog[i].UpdateAnimFunction then
self.MessageObjectLog[i].UpdateAnimFunction(dtScale, CurveUtil)
end
end
end
|
-- This is for the buttons effects.
-- Edit if you know what you are doing. |
local button = script.Parent
local leftarrow = script.Parent.LeftArrow
local rightarrow = script.Parent.RightArrow
local TweenService = game:GetService("TweenService")
local TweenSpeed = 0.1
local Info = TweenInfo.new(TweenSpeed, Enum.EasingStyle.Quad, Enum.EasingDirection.In, 0)
|
--[[
Teleports all players to within the specified part
]] |
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local PlayerManager = require(ServerStorage.Source.Managers.PlayerManager)
return function(spawnPart)
for _, player in pairs(Players:GetPlayers()) do
if player.Character and player.Character.PrimaryPart then
local primaryPart = player.Character.PrimaryPart
if primaryPart:CanSetNetworkOwnership() then
primaryPart:SetNetworkOwner(nil)
end
local cFrame =
spawnPart.CFrame *
CFrame.new(
math.random(-spawnPart.Size.X * 0.5 * 100, spawnPart.Size.X * 0.5 * 100) / 100,
3,
math.random(-spawnPart.Size.Z * 0.5 * 100, spawnPart.Size.Z * 0.5 * 100) / 100
)
primaryPart.CFrame = cFrame
if primaryPart:CanSetNetworkOwnership() then
primaryPart:SetNetworkOwner(player)
end
else
local serverPlayerComponent = PlayerManager.getFromPlayer(player)
if serverPlayerComponent and serverPlayerComponent.status.currentState == "game" then
serverPlayerComponent.stateMachine:get():startSpectating()
end
end
end
end
|
--Makes sure the part is scaled properly---------- |
local function Confirm(Grid, Plot)
if X % Grid ~= 0 then
X = math.clamp(X - 1, 1, 78)
Confirm(Grid, Plot)
end
if Z % Grid ~= 0 then
Z = math.clamp(Z - 1, 1, 78)
Confirm(Grid, Plot)
end
end
|
--== OK DEVON MAKE THIS ==-- |
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local TS = game:GetService("TweenService")
local Player = Players.LocalPlayer
local Character = script.Parent
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
local camera = workspace.Camera
repeat wait() until Humanoid
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local Torso = Character:WaitForChild("Torso")
local RootJoint = HumanoidRootPart:WaitForChild("RootJoint")
local function Lerp(a, b, c)
return a + (b - a) * c
end
local Force = nil
local Direction = nil
local Value1 = 0
local Value2 = 0
local RootJointC0 = RootJoint.C0
RunService.RenderStepped:Connect(function()
Force = HumanoidRootPart.Velocity * Vector3.new(0.2, 0, 0.2)
if Force.Magnitude > 2 then
Direction = Force.Unit
Value1 = HumanoidRootPart.CFrame.RightVector:Dot(Direction)
Value2 = HumanoidRootPart.CFrame.LookVector:Dot(Direction)
else
Value1 = 0
Value2 = 0
end
RootJoint.C0 = RootJoint.C0:Lerp(RootJointC0 * CFrame.Angles(math.rad(Value2 * 8), math.rad(-Value1 * 7), 0), 0.2)
end)
|
-- |
wait(1)
powerlmp.Value = true
function Alert()
script.Parent.Assembly.Sound.Click:Play()
script.AttackScript.Disabled = true
script.Parent.Parent.On.Value = true
end
function Test()
script.Parent.Assembly.Sound.Click:Play()
script.AttackScript.Disabled = true
script.Parent.Parent.On.Value = true
end
function Fire()
script.Parent.Assembly.Sound.Click:Play()
script.AttackScript.Disabled = true
script.Parent.Parent.On.Value = true
script.Parent.Parent.Parent.FederalSignalRC6.Modulate.Value = true
end
function Attack()
script.AttackScript.Disabled = false
end
function Cancel()
script.Parent.Assembly.Sound.Click:Play()
script.AttackScript.Disabled = true
script.Parent.Values.Mode.Value = 4
signallmp.Value = false
script.Parent.Parent.On.Value = false
script.Parent.Parent.Parent.FederalSignalRC6.Modulate.Value = false
script.Parent.Values.TimerOn.Value = false
end
function Timer()
script.Timer.Disabled = false
signallmp.Value = true
end
script.Parent.Values.TimerOn.Changed:connect(function()
if script.Parent.Values.TimerOn.Value == true then
if script.Parent.Values.Mode.Value == 2 then
Alert()
Timer()
elseif script.Parent.Values.Mode.Value == 3 then
Attack()
Timer()
elseif script.Parent.Values.Mode.Value == 5 then
Fire()
Timer()
elseif script.Parent.Values.Mode.Value == 1 then
Test()
elseif script.Parent.Values.Mode.Value == 4 then
script.AttackScript.Disabled = true
Cancel()
end
end
end)
script.Parent.Values.Mode.Changed:connect(function()
if script.Parent.Values.Mode.Value == 4 then
Cancel()
end
end)
|
-- ====================
-- BASIC
-- A basic settings for the gun
-- ==================== |
Auto = false;
MuzzleOffset = Vector3.new(0, 0.625, 1.25);
BaseDamage = 25;
FireRate = 0.05; --In second
ReloadTime = 2.7; --In second
AmmoPerClip = 5; --Put "math.huge" to make this gun has infinite ammo and never reload
Spread = 1.25; --In degree
HeadshotEnabled = true; --Enable the gun to do extra damage on headshot
HeadshotDamageMultiplier = 3;
MouseIconID = "316279304";
HitSoundIDs = {186809061,186809249,186809250,186809252};
IdleAnimationID = 94331086; --Set to "nil" if you don't want to animate
IdleAnimationSpeed = 1;
FireAnimationID = 94332152; --Set to "nil" if you don't want to animate
FireAnimationSpeed = 6;
ReloadAnimationID = nil; --Set to "nil" if you don't want to animate
ReloadAnimationSpeed = 1;
|
--RAIN PHYSICS / GENERATION |
local RainFallSpeed = 150 --Studs the rain falls per second
local RainGroupsPerSecond = 400 --Amount of rain drops per second
local RainRadius = 200 --Radius from the camera in studs where rain drops will spawn
local StartY = 100 --Start height of the rain
local DefaultEndY = -10 --Default end height of the rain. Can be overriden for certain zones
local WindSpeedX = 0 --Wind speed in studs on X axis
local WindSpeedZ = 0 --Wind speed in studs on Z axis
|
-- Testing AC FE support |
local event = script.Parent
local car=script.Parent.Parent
local LichtNum = 0
event.OnServerEvent:connect(function(player,data)
if data['ToggleLight'] then
if car.Body.Light.on.Value==true then
car.Body.Light.on.Value=false
else
car.Body.Light.on.Value=true
end
elseif data['EnableBrakes'] then
car.Body.Lights.Brake.Value=true
elseif data['DisableBrakes'] then
car.Body.Lights.Brake.Value=false
elseif data['ToggleLeftBlink'] then
if car.Body.Lights.Left.Value==true then
car.Body.Lights.Left.Value=false
else
car.Body.Lights.Left.Value=true
car.Body.Lights.Right.Value=false
end
elseif data['ToggleRightBlink'] then
if car.Body.Lights.Right.Value==true then
car.Body.Lights.Right.Value=false
else
car.Body.Lights.Right.Value=true
car.Body.Lights.Left.Value=false
end
elseif data['ReverseOn'] then
car.Body.Lights.Reverse.Value=true
elseif data['ReverseOff'] then
car.Body.Lights.Reverse.Value=false
elseif data['ToggleStandlicht'] then
if LichtNum == 0 then
LichtNum = 2
car.Body.Lights.Headlights.Value = true
elseif LichtNum == 1 then
LichtNum = 2
car.Body.Lights.Headlights.Value = true
elseif LichtNum == 2 then
LichtNum = 3
car.Body.Lights.HiBeams.Value = true
elseif LichtNum == 3 then
LichtNum = 1
car.Body.Lights.Headlights.Value = false
car.Body.Lights.HiBeams.Value = false
end
elseif data["ToggleHazards"] then
if car.Body.Lights.Hazards == false then
car.Body.Lights.Right.Value=false
car.Body.Lights.Left.Value=false
elseif car.Body.Lights.Hazards == true then
car.Body.Lights.Right.Value=true
car.Body.Lights.Left.Value=true
end
end
end)
|
----------------------------------------------------------------------------------------------------
-----------------=[ RECOIL & PRECISAO ]=------------------------------------------------------------
---------------------------------------------------------------------------------------------------- |
,VRecoil = {13,17} --- Vertical Recoil
,HRecoil = {6,8} --- Horizontal Recoil
,AimRecover = .75 ---- Between 0 & 1
,RecoilPunch = .15
,VPunchBase = 2.75 --- Vertical Punch
,HPunchBase = 1.35 --- Horizontal Punch
,DPunchBase = 1 --- Tilt Punch | useless
,AimRecoilReduction = 5 --- Recoil Reduction Factor While Aiming (Do not set to 0)
,PunchRecover = 0.2
,MinRecoilPower = .5
,MaxRecoilPower = 3.5
,RecoilPowerStepAmount = .25
,MinSpread = 1.25 --- Min bullet spread value | Studs
,MaxSpread = 40 --- Max bullet spread value | Studs
,AimInaccuracyStepAmount = 0.75
,WalkMultiplier = 0 --- Bullet spread based on player speed
,SwayBase = 0.25 --- Weapon Base Sway | Studs
,MaxSway = 1.5 --- Max sway value based on player stamina | Studs |
-- A state object whose value can be set at any time by the user. |
export type Value<T> = StateObject<T> & {
-- kind: "State" (add this when Luau supports singleton types)
set: (Value<T>, newValue: any, force: boolean?) -> ()
}
|
--------------------) Settings |
Damage = 0 -- the ammout of health the player or mob will take
Cooldown = 5 -- cooldown for use of the tool again
ZoneModelName = "Negative zone" -- name the zone model
MobHumanoidName = "Humanoid"-- the name of player or mob u want to damage |
--- Mouse lock (prevents from being unable to zoom in first person because scrollframes |
GUI.ToggleMouseLock = function(newState)
newState = (newState ~= nil and newState or false)
--
if not lockMouse then
local lockMouseScreen = Instance.new("ScreenGui")
lockMouseScreen.Name = "LockMouse"
lockMouseScreen.Parent = playerGui
--
lockMouse = Instance.new("TextButton")
lockMouse.Visible = false
lockMouse.BackgroundTransparency = 1
lockMouse.Text = ""
lockMouse.BorderSizePixel = 0
lockMouse.Size = UDim2.new(0, 1, 0, 1)
lockMouse.Parent = lockMouseScreen
end
--
lockMouse.Modal = newState
lockMouse.Visible = newState
end
GUI.ToggleCursor = function(newState)
newState = (newState ~= nil and newState or false)
--
_L.Services.UserInputService.MouseIconEnabled = newState
end
|
--dont change any thing beside the these numbers--
--to change explosion force go to CannonBall script--
---------------------------------------------------------------------------------------------------------------------------------------------------- |
local missile = Instance.new("Part")
local barrel
if gunOne == true then
barrel = gunBarrelOne
gunOne = true
end
local spawnPos = barrel.CFrame * Vector3.new(5, 0, 0)
local dx = math.random(50-cannonAcc,50+cannonAcc)
local dy = math.random(targetRange-5,targetRange+5)
local dz = math.random(0-cannonAcc,0+cannonAcc)
local mag = math.random(power,power)
local v = barrel.CFrame:vectorToWorldSpace(Vector3.new(mag + dx,dy,dz))
local missile = cannonBall:clone()
missile.Position = spawnPos
missile.Velocity = v
local new_script = script.Parent.CannonBall:clone()
new_script.Disabled = false
new_script.Parent = missile
local creator_tag = Instance.new("ObjectValue")
creator_tag.Value = player
creator_tag.Name = "creator"
creator_tag.Parent = missile
missile.Parent = game.Workspace
local effect=script.Parent.Parent.Effect
local fire = effect.Fire
local smoke1 = effect.Smoke
local smoke2 = effect.Smoke1
fire.Enabled = true
smoke1.Enabled = true
smoke2.Enabled = true
wait(0.3)
fire.Enabled = false
wait(0.5)
smoke1.Enabled =false
smoke2.Enabled = false
end
function onClicked()
local reloadTime = 10-- +1
if debounce == false then
debounce = true
switch.BrickColor = BrickColor.new(21)
fire(player)
wait(reloadTime)
debounce = false
switch.BrickColor = BrickColor.new(37)
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
|
-- Decompiled with the Synapse X Luau decompiler. |
local v1 = script:FindFirstAncestor("MainUI");
local l__Bricks__2 = game:GetService("ReplicatedStorage"):WaitForChild("Bricks");
local l__TweenService__1 = game:GetService("TweenService");
return function(p1)
local l__FigureCamPos__3 = workspace:FindFirstChild("FigureCamPos", true);
p1.stopcam = true;
p1.freemouse = true;
p1.hideplayers = 2;
p1.update();
local l__WorldCFrame__4 = l__FigureCamPos__3.CamPos1.WorldCFrame;
local l__WorldCFrame__5 = l__FigureCamPos__3.CamPos2.WorldCFrame;
local l__CFrame__6 = p1.cam.CFrame;
local v7 = tick() + 3;
local l__FieldOfView__8 = p1.cam.FieldOfView;
l__TweenService__1:Create(p1.cam, TweenInfo.new(3, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {
FieldOfView = 60
}):Play();
for v9 = 1, 100000 do
task.wait();
if not (tick() <= v7) then
break;
end;
p1.cam.CFrame = l__CFrame__6:Lerp(l__WorldCFrame__4, (l__TweenService__1:GetValue((3 - math.abs(tick() - v7)) / 3, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut))) * p1.csgo;
end;
local v10 = tick() + 5.5;
l__TweenService__1:Create(p1.cam, TweenInfo.new(7.8, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {
FieldOfView = 70
}):Play();
for v11 = 1, 100000 do
task.wait();
if not (tick() <= v10) then
break;
end;
p1.cam.CFrame = l__WorldCFrame__4:Lerp(l__WorldCFrame__5, (l__TweenService__1:GetValue((5.5 - math.abs(tick() - v10)) / 5.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut))) * p1.csgo;
end;
local l__CFrame__12 = p1.cam.CFrame;
local v13 = tick() + 0.5;
local l__FieldOfView__14 = p1.cam.FieldOfView;
for v15 = 1, 100000 do
task.wait();
local v16 = l__TweenService__1:GetValue((0.5 - math.abs(tick() - v13)) / 0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut);
if not (tick() <= v13) then
break;
end;
p1.cam.CFrame = l__CFrame__12:Lerp(p1.basecamcf, v16) * p1.csgo;
p1.cam.FieldOfView = l__FieldOfView__14 + (p1.fovspring - l__FieldOfView__14) * v16;
end;
p1.stopcam = false;
p1.freemouse = false;
p1.hideplayers = 0;
p1.update();
end;
|
--lonely function |
local function getParts(parent)
local parts = {}
local descendants = parent:GetDescendants()
for i = 1, #descendants do
local part = descendants[i]
if part:IsA("BasePart") then
parts[#parts + 1] = part
end
end
return parts
end
|
-- Initialize texture tool |
local TextureTool = require(CoreTools:WaitForChild 'Texture')
Core.AssignHotkey('G', Core.Support.Call(Core.EquipTool, TextureTool));
Core.AddToolButton(Core.Assets.TextureIcon, 'G', TextureTool)
|
-- originalEndWaypoint is optional, causes the waypoint to tween from that position. |
function ClickToMoveDisplay.CreatePathDisplay(wayPoints, originalEndWaypoint)
createPathCount = createPathCount + 1
local trailDots = createTrailDots(wayPoints, originalEndWaypoint)
local function removePathBeforePoint(wayPointNumber)
-- kill all trailDots before and at wayPointNumber
for i = #trailDots, 1, -1 do
local trailDot = trailDots[i]
if trailDot.ClosestWayPoint <= wayPointNumber then
trailDot:Destroy()
trailDots[i] = nil
else
break
end
end
end
local reiszeTrailDotsUpdateName = "ClickToMoveResizeTrail" ..createPathCount
local function resizeTrailDots()
if #trailDots == 0 then
RunService:UnbindFromRenderStep(reiszeTrailDotsUpdateName)
return
end
local cameraPos = Workspace.CurrentCamera.CFrame.p
for i = 1, #trailDots do
local trailDotImage: ImageHandleAdornment = trailDots[i].DisplayModel:FindFirstChild("TrailDotImage")
if trailDotImage then
local distanceToCamera = (trailDots[i].DisplayModel.Position - cameraPos).magnitude
trailDotImage.Size = getTrailDotScale(distanceToCamera, TrailDotSize)
end
end
end
RunService:BindToRenderStep(reiszeTrailDotsUpdateName, Enum.RenderPriority.Camera.Value - 1, resizeTrailDots)
local function removePath()
removePathBeforePoint(#wayPoints)
end
return removePath, removePathBeforePoint
end
local lastFailureWaypoint = nil
function ClickToMoveDisplay.DisplayFailureWaypoint(position)
if lastFailureWaypoint then
lastFailureWaypoint:Hide()
end
local failureWaypoint = FailureWaypoint.new(position)
lastFailureWaypoint = failureWaypoint
coroutine.wrap(function()
failureWaypoint:RunFailureTween()
failureWaypoint:Destroy()
failureWaypoint = nil
end)()
end
function ClickToMoveDisplay.CreateEndWaypoint(position)
return EndWaypoint.new(position)
end
function ClickToMoveDisplay.PlayFailureAnimation()
local myHumanoid = findPlayerHumanoid()
if myHumanoid then
local animationTrack = getFailureAnimationTrack(myHumanoid)
animationTrack:Play()
end
end
function ClickToMoveDisplay.CancelFailureAnimation()
if lastFailureAnimationTrack ~= nil and lastFailureAnimationTrack.IsPlaying then
lastFailureAnimationTrack:Stop()
end
end
function ClickToMoveDisplay.SetWaypointTexture(texture)
TrailDotIcon = texture
TrailDotTemplate, EndWaypointTemplate, FailureWaypointTemplate = CreateWaypointTemplates()
end
function ClickToMoveDisplay.GetWaypointTexture()
return TrailDotIcon
end
function ClickToMoveDisplay.SetWaypointRadius(radius)
TrailDotSize = Vector2.new(radius, radius)
TrailDotTemplate, EndWaypointTemplate, FailureWaypointTemplate = CreateWaypointTemplates()
end
function ClickToMoveDisplay.GetWaypointRadius()
return TrailDotSize.X
end
function ClickToMoveDisplay.SetEndWaypointTexture(texture)
EndWaypointIcon = texture
TrailDotTemplate, EndWaypointTemplate, FailureWaypointTemplate = CreateWaypointTemplates()
end
function ClickToMoveDisplay.GetEndWaypointTexture()
return EndWaypointIcon
end
function ClickToMoveDisplay.SetWaypointsAlwaysOnTop(alwaysOnTop)
WaypointsAlwaysOnTop = alwaysOnTop
TrailDotTemplate, EndWaypointTemplate, FailureWaypointTemplate = CreateWaypointTemplates()
end
function ClickToMoveDisplay.GetWaypointsAlwaysOnTop()
return WaypointsAlwaysOnTop
end
return ClickToMoveDisplay
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.