local chr = owner.Character
local hum = chr:FindFirstChildWhichIsA("Humanoid")
chr.Parent = game:GetService("ReplicatedStorage")
script.Name = "fakeChrModel" .. owner.Name
local root, torso, head, la, ra, ll, rl, blaster, sword, shield, le, re
local rj, nk, ls, rs, lh, rh
local rjc0, nkc0, lsc0, rsc0, lhc0, rhc0
local refit = false
local random = Random.new()
local currentBass = 1
local currentPing = 1
local currentSnap = 1
local songPlaying = false
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.IgnoreWater = true
raycastParams.RespectCanCollide = true
raycastParams.FilterDescendantsInstances = {script}
local overlapParams = OverlapParams.new()
overlapParams.FilterType = Enum.RaycastFilterType.Exclude
overlapParams.RespectCanCollide = true
overlapParams.FilterDescendantsInstances = {script}
local soundTable = {
["Bass"] = {};
["Ping"] = {};
["Snap"] = {}
}
for i = 1, 3 do
for s = 1, 6 do
local sEffect = Instance.new("Sound")
sEffect.Volume = 1.4
if i == 1 then
sEffect.SoundId = "rbxasset://sounds/bass.mp3"
table.insert(soundTable["Bass"], sEffect)
elseif i == 2 then
sEffect.SoundId = "rbxasset://sounds/electronicpingshort.wav"
table.insert(soundTable["Ping"], sEffect)
elseif i == 3 then
sEffect.SoundId = "rbxasset://sounds/snap.mp3"
table.insert(soundTable["Snap"], sEffect)
end
end
end
function playSound(s, p)
if s == "bass" then
currentBass += 1
if currentBass > #soundTable["Bass"] then
currentBass = 1
end
local sound = soundTable["Bass"][currentBass]
sound.TimePosition = 0.12
sound.Pitch = p
sound.Playing = true
return sound
elseif s == "ping" then
currentPing += 1
if currentPing > #soundTable["Ping"] then
currentPing = 1
end
local sound = soundTable["Ping"][currentPing]
sound.TimePosition = 0.2
sound.Pitch = p
sound.Playing = true
return sound
elseif s == "snap" then
currentSnap += 1
if currentSnap > #soundTable["Snap"] then
currentSnap = 1
end
local sound = soundTable["Snap"][currentSnap]
sound.TimePosition = 0.2
sound.Pitch = p
sound.Playing = true
return sound
end
end
local idleSong = {
["Tempo"] = 240,
["Patterns"] = {
[1] = {
[1] = {"note", 3.6},
[2] = {"note", 1.8, 7},
[3] = {"note", 2.64},
[4] = {"note", 3.6},
[5] = {"note", 4.2},
[6] = {"note", 4.8},
[7] = {"note", 1.8, 1},
[8] = {"note", 4.24},
[9] = {"note", 2.8},
[10] = {"note", 1.4, 7},
[11] = {"note", 2.64},
[12] = {"note", 3.6},
[13] = {"note", 4.2},
[14] = {"note", 4.8},
[15] = {"note", 1.4, 1},
[16] = {"note", 4.24},
[17] = {"note", 2.4},
[18] = {"note", 1.2, 7},
[19] = {"note", 2.64},
[20] = {"note", 3.6},
[21] = {"note", 4.2},
[22] = {"note", 4.8},
[23] = {"note", 1.2, 1},
[24] = {"note", 4.24},
[25] = {"note", 2.64},
[26] = {"note", 1.32, 7},
[27] = {"note", 2.64},
[28] = {"note", 3.6},
[29] = {"note", 4.2},
[30] = {"note", 4.8},
[31] = {"note", 1.32, 1},
[32] = {"note", 4.24},
[33] = {"repeat", 1}
},
[2] = {
[1] = {"note", 0.9},
[2] = {"note", 1.8},
[3] = {"note", 1.6},
[4] = {"note", 1.4},
[5] = {"note", 1.6},
[6] = {"note", 1.4},
[7] = {"note", 1.325},
[8] = {"note", 1.4},
[9] = {"note", 1.325},
[10] = {"note", 1.2},
[11] = {"note", 1.325},
[12] = {"note", 1.2},
[13] = {"note", 1.325},
[14] = {"note", 1.4},
[15] = {"note", 1.325},
[16] = {"note", 1.2},
[17] = {"note", 0.7},
[18] = {"note", 0.788},
[19] = {"note", 0.9},
[20] = {"note", 0.788},
[21] = {"note", 0.9},
[22] = {"note", 1},
[23] = {"note", 0.9},
[24] = {"note", 1},
[25] = {"note", 1.09},
[26] = {"note", 1},
[27] = {"note", 1.09},
[28] = {"note", 1.2},
[29] = {"note", 1.09},
[30] = {"note", 1.2},
[31] = {"note", 1.325},
[32] = {"note", 1.425},
[33] = {"note", 0.6},
[34] = {"note", 1.2},
[35] = {"note", 1.075},
[36] = {"note", 0.933},
[37] = {"note", 1.075},
[38] = {"note", 0.933},
[39] = {"note", 0.883},
[40] = {"note", 0.933},
[41] = {"note", 0.883},
[42] = {"note", 0.8},
[43] = {"note", 0.883},
[44] = {"note", 0.8},
[45] = {"note", 0.883},
[46] = {"note", 0.933},
[47] = {"note", 0.883},
[48] = {"note", 0.8},
[49] = {"note", 0.675},
[50] = {"note", 0.75},
[51] = {"note", 0.85},
[52] = {"note", 0.75},
[53] = {"note", 0.85},
[54] = {"note", 0.9},
[55] = {"note", 0.85},
[56] = {"note", 0.9},
[57] = {"note", 1},
[58] = {"note", 0.9},
[59] = {"note", 1},
[60] = {"note", 1.05},
[61] = {"note", 1},
[62] = {"note", 1.05},
[63] = {"note", 1.18},
[64] = {"note", 1.35},
[65] = {"repeat", 1}
}
}
}
local sounds = {
["PlaySong"] = function(song)
task.spawn(function()
songPlaying = true
local currentPattern = 1
local currentNote = 0
local repeatCounter = 0
local noteRepeatCounter = 0
local tempo = 60 / song["Tempo"]
local patterns = song["Patterns"]
while true do
if currentNote > 0 then
if patterns[currentPattern][currentNote][3] == nil then
currentNote += 1
else
if noteRepeatCounter < patterns[currentPattern][currentNote][3] then
noteRepeatCounter += 1
else
currentNote += 1
noteRepeatCounter = 0
end
end
else
currentNote = 1
end
if patterns[currentPattern][currentNote][1] == "repeat" then
if repeatCounter < patterns[currentPattern][currentNote][2] then
currentNote = 1
repeatCounter += 1
else
currentPattern += 1
if currentPattern > #patterns then
songPlaying = false
break
end
currentNote = 1
repeatCounter = 0
end
end
local bass = playSound("bass", patterns[currentPattern][currentNote][2])
task.wait(tempo)
bass.Playing = false
end
end)
end;
["EHAHA"] = function()
task.spawn(function()
for i = 1, 6 do
local sound = playSound("bass", 3 + i * 0.175)
task.wait(0.03)
sound.Playing = false
end
for e = 1, 9 do
for i = 1, 4 do
local sound = playSound("bass", 4 - e * 0.2 + i * 0.4)
task.wait(0.03)
sound.Playing = false
end
end
end)
end;
["DeathSound"] = function()
task.spawn(function()
for i = 1, 17 do
local sound = playSound("ping", 1.55 + i * 0.05)
if i % 2 == 0 then
sound = playSound("ping", (sound.Pitch - 0.05) / 2)
end
task.wait(0.06)
end
for i = 1, 20 do
local sound = playSound("snap", i * 0.1)
task.wait(0.02)
end
for i = 1, 20 do
local sound = playSound("snap", 2.1 - i * 0.1)
task.wait(0.02)
end
end)
end;
["HitSound"] = function()
task.spawn(function()
local c = random:NextInteger(1, 3)
if c == 1 then
for i = 1, 10 do
playSound("snap", 1.5 - i * 0.1)
task.wait(0.04)
end
elseif c == 2 then
playSound("snap", 0.6)
task.wait(0.08)
playSound("snap", 1.2)
task.wait(0.08)
elseif c == 3 then
for i = 1, 5 do
playSound("snap", i * 0.25)
task.wait(0.04)
end
end
end)
end;
["BANG"] = function()
task.spawn(function()
local rPitch = random:NextNumber(1, 1.4)
for i = 1, 2 do
playSound("snap", 0.8 * rPitch)
task.wait(0.04)
end
for i = 1, 10 do
playSound("snap", 0.325 * rPitch - i * 0.02)
task.wait(0.04)
end
end)
end;
["ZAP"] = function()
task.spawn(function()
for i = 1, 6 do
playSound("bass", 2.3 * random:NextInteger(1, 2))
task.wait(0.04)
end
for i = 1, 6 do
playSound("bass", 1.15 * random:NextInteger(1, 2))
task.wait(0.04)
end
end)
end;
["Shatter"] = function()
task.spawn(function()
for i = 1, 20 do
playSound("ping", random:NextNumber(1.6, 4.2))
playSound("snap", random:NextNumber(1.5, 2.5))
task.wait(random:NextNumber(0.01, i / 100))
end
end)
end;
["Kaboom"] = function()
task.spawn(function()
local c = random:NextInteger(1, 3)
if c == 1 then
for i = 1, 30 do
playSound("snap", 0.6 - i * 0.015)
task.wait(0.06)
end
elseif c == 2 then
for i = 1, 20 do
playSound("snap", (2 / i) + 0.2)
task.wait(0.02)
end
elseif c == 3 then
for i = 1, 3 do
playSound("snap", 3.4)
task.wait(0.03)
end
for i = 1, 20 do
playSound("snap", 1.4 - i * 0.06)
task.wait(0.03)
end
end
end)
end;
["FallSound"] = function()
task.spawn(function()
for i = 1, 30 do
playSound("ping", 4 - i * 0.06)
task.wait(0.06)
end
end)
end;
["LaunchSound"] = function()
task.spawn(function()
for i = 1, 20 do
playSound("snap", i * 0.1)
task.wait(0.02)
end
for i = 1, 20 do
playSound("bass", 10 - i * 0.26)
playSound("snap", 2.1 - i * 0.1)
task.wait(0.02)
end
end)
end;
["Dong"] = function()
task.spawn(function()
playSound("bass", 9.2)
playSound("ping", 2.64)
playSound("snap", 2)
task.wait(0.06)
for i = 1,4 do
playSound("bass", 12.6)
playSound("ping", 3.6)
task.wait(0.06)
end
end)
end;
["ShootSound"] = function()
task.spawn(function()
for i = 1, 7 do
local bass = playSound("bass", 10 - i * 0.8)
local snap = playSound("snap", 0)
if i < 3 then
snap.Pitch = 2
end
task.wait(0.02)
bass.Playing = false
snap.Playing = false
end
end)
end;
["OW"] = function()
task.spawn(function()
for i = 1, 3 do
local bass = playSound("bass", 9 + i * 0.3)
task.wait(0.04)
bass.Playing = false
end
for i = 1, 4 do
local bass = playSound("bass", 9.75 - i * 0.6)
task.wait(0.04)
bass.Playing = false
end
end)
end;
["AOW"] = function()
task.spawn(function()
for i = 1, 40 do
local pit = 2.5 + (i + 38) * 0.15
if i > 8 then
pit = 9 - (i - 4) * 0.15
end
local bass = playSound("bass", pit)
task.wait(0.04)
bass.Playing = false
end
end)
end;
["Collide"] = function()
task.spawn(function()
local c = math.random(1,2)
if c == 1 then
for i = 1, 3 do
local snap = playSound("snap", 1)
task.wait(0.04)
snap.Playing = false
end
elseif c == 2 then
for i = 1, 2 do
local snap = playSound("snap", 0.9)
task.wait(0.04)
snap.Playing = false
task.wait(0.04)
end
end
end)
end;
["RecoverSound"] = function()
task.spawn(function()
for i = 1, 15 do
local ping = playSound("ping", i * 0.3)
task.wait(0.06)
ping.Playing = false
end
end)
end;
["SwingSound"] = function()
task.spawn(function()
for i = 1, 5 do
local snap = playSound("snap", 1 + i * 0.1)
task.wait(0.04)
snap.Playing = false
end
end)
end;
["Swoosh"] = function()
task.spawn(function()
local rPitch = random:NextNumber(0.8, 1.4)
for i = 1, 5 do
local snap = playSound("snap", 0.5 * rPitch + i * 0.12)
task.wait(0.04)
snap.Playing = false
end
for i = 1, 5 do
local snap = playSound("snap", 1.1 * rPitch - i * 0.12)
task.wait(0.04)
snap.Playing = false
end
end)
end;
["Ding"] = function()
task.spawn(function()
playSound("bass", 12.5)
playSound("bass", 3.6)
task.wait(0.06)
for i = 1, 4 do
playSound("bass", 19)
playSound("ping", 5.3)
task.wait(0.06)
end
end)
end;
["AHAHA"] = function()
task.spawn(function()
for i = 1, 6 do
local bass = playSound("bass", 4 + i * 0.3)
task.wait(0.03)
bass.Playing = false
end
for e = 1, 9 do
for i = 1, 4 do
local bass = playSound("bass", 6 - e * 0.4 + i * 0.6)
task.wait(0.03)
bass.Playing = false
end
end
end)
end;
["YAH"] = function()
task.spawn(function()
for i = 1, 3 do
local bass = playSound("bass", i * 3)
task.wait(0.03)
bass.Playing = false
end
for i = 1, 2 do
local bass = playSound("bass", 9)
task.wait(0.03)
bass.Playing = false
end
for i = 1, 8 do
local bass = playSound("bass", 6 - i * 0.3)
task.wait(0.04)
bass.Playing = false
end
end)
end;
["YO"] = function()
task.spawn(function()
for i = 1, 3 do
local bass = playSound("bass", i * 2)
task.wait(0.03)
bass.Playing = false
end
for i = 1, 2 do
local bass = playSound("bass", 6)
task.wait(0.03)
bass.Playing = false
end
for i = 1, 5 do
local bass = playSound("bass", 4 - i * 0.3)
task.wait(0.04)
bass.Playing = false
end
end)
end;
["HealField"] = function()
task.spawn(function()
for i = 1, 30 do
playSound("snap", 0.3 + i * 0.03)
task.wait(0.06)
end
end)
task.spawn(function()
for i = 1, 3 do
playSound("snap", 0.5)
task.wait(0.02)
end
for i = 1, 9 do
local bass = playSound("bass", -0.12 * (i - 6) ^ 2 + 9)
task.wait(0.04)
bass.Playing = false
end
for i = 1, 3 do
playSound("snap", 0.8)
task.wait(0.02)
end
for i = 1, 14 do
local bass = playSound("bass", -0.03 * (i - 4) ^ 2 + 7.5)
task.wait(0.04)
bass.Playing = false
end
end)
end
}
local function createPart(n, s, m, c, t, p)
local limb = Instance.new("Part")
limb.Name = n
limb.Size = s
limb.Material = m
limb.Color = c
limb.Transparency = t
limb.Parent = p
limb.CanCollide = false
limb.CanQuery = false
limb.Anchored = true
limb.Locked = true
return limb
end
local function IsInWater(pos)
local region = Region3.new(pos - Vector3.one*4, pos + Vector3.one*4)
return workspace.Terrain:ReadVoxels(region, 4)[1][1][1] == Enum.Material.Water
end
local weld = {}
weld.__index = weld
function weld.new(p0, p1, c0, c1)
local self = setmetatable({}, weld)
self.part0 = p0
self.part1 = p1
self.c0 = c0
self.c1 = c1
return self
end
function weld:Enforce()
self.part1.CFrame = self.part0.CFrame * self.c0 * self.c1:Inverse()
end
local previousCF = chr.HumanoidRootPart.Position
local lights = {}
local blasterParts = {}
local function createChr()
local fakeChr = Instance.new("Model")
fakeChr.Name = "fakeChr" .. owner.Name
fakeChr.Parent = script
root = createPart("r", Vector3.new(2, 2, 1), Enum.Material.DiamondPlate, Color3.new(), 1, fakeChr)
root.Position = previousCF
cam = createPart("c", Vector3.new(1, 1, 1), Enum.Material.DiamondPlate, Color3.new(), 1, script)
head = createPart("h", Vector3.new(1, 1, 1), Enum.Material.Metal, Color3.fromRGB(163, 162, 165), 0, fakeChr)
torso = createPart("t", Vector3.new(2, 2, 1), Enum.Material.Metal, Color3.new(1, 0, 0), 0, fakeChr)
lights = {
[1] = {createPart("fTX1", Vector3.new(0.1, 2, 0.01), Enum.Material.Neon, Color3.fromRGB(255, 89, 89), 0, fakeChr), CFrame.new(0, 0, -0.51) * CFrame.Angles(0, 0, math.rad(45))};
[2] = {createPart("fTX2", Vector3.new(0.1, 2, 0.01), Enum.Material.Neon, Color3.fromRGB(255, 89, 89), 0, fakeChr), CFrame.new(0, 0, -0.51) * CFrame.Angles(0, 0, -math.rad(45))};
[3] = {createPart("bTX1", Vector3.new(0.1, 2, 0.01), Enum.Material.Neon, Color3.fromRGB(255, 89, 89), 0, fakeChr), CFrame.new(0, 0, 0.51) * CFrame.Angles(0, 0, math.rad(45))};
[4] = {createPart("bTX2", Vector3.new(0.1, 2, 0.01), Enum.Material.Neon, Color3.fromRGB(255, 89, 89), 0, fakeChr), CFrame.new(0, 0, 0.51) * CFrame.Angles(0, 0, -math.rad(45))};
[5] = {createPart("sTL1", Vector3.new(0.01, 0.6, 0.1), Enum.Material.Neon, Color3.fromRGB(255, 89, 89), 0, fakeChr), CFrame.new(-1.01, -0.5, 0)};
[6] = {createPart("sTL2", Vector3.new(0.01, 0.6, 0.1), Enum.Material.Neon, Color3.fromRGB(255, 89, 89), 0, fakeChr), CFrame.new(1.01, -0.5, 0)};
[7] = {createPart("sLLL1", Vector3.new(0.01, 0.6, 0.1), Enum.Material.Neon, Color3.fromRGB(82, 124, 174), 0, fakeChr), CFrame.new(-0.51, 0.5, 0)};
[8] = {createPart("sLLL2", Vector3.new(0.01, 0.6, 0.1), Enum.Material.Neon, Color3.fromRGB(82, 124, 174), 0, fakeChr), CFrame.new(-0.51, -0.5, 0)};
[9] = {createPart("fLLL1", Vector3.new(0.1, 0.6, 0.01), Enum.Material.Neon, Color3.fromRGB(82, 124, 174), 0, fakeChr), CFrame.new(0, 0.5, -0.51)};
[10] = {createPart("fLLL2", Vector3.new(0.1, 0.6, 0.01), Enum.Material.Neon, Color3.fromRGB(82, 124, 174), 0, fakeChr), CFrame.new(0, -0.5, -0.51)};
[11] = {createPart("bLLL1", Vector3.new(0.1, 0.6, 0.01), Enum.Material.Neon, Color3.fromRGB(82, 124, 174), 0, fakeChr), CFrame.new(0, 0.5, 0.51)};
[12] = {createPart("bLLL2", Vector3.new(0.1, 0.6, 0.01), Enum.Material.Neon, Color3.fromRGB(82, 124, 174), 0, fakeChr), CFrame.new(0, -0.5, 0.51)};
[13] = {createPart("sRLL1", Vector3.new(0.01, 0.6, 0.1), Enum.Material.Neon, Color3.fromRGB(82, 124, 174), 0, fakeChr), CFrame.new(0.51, 0.5, 0)};
[14] = {createPart("sRLL2", Vector3.new(0.01, 0.6, 0.1), Enum.Material.Neon, Color3.fromRGB(82, 124, 174), 0, fakeChr), CFrame.new(0.51, -0.5, 0)};
[15] = {createPart("fRLL1", Vector3.new(0.1, 0.6, 0.01), Enum.Material.Neon, Color3.fromRGB(82, 124, 174), 0, fakeChr), CFrame.new(0, 0.5, -0.51)};
[16] = {createPart("fRLL2", Vector3.new(0.1, 0.6, 0.01), Enum.Material.Neon, Color3.fromRGB(82, 124, 174), 0, fakeChr), CFrame.new(0, -0.5, -0.51)};
[17] = {createPart("bRLL1", Vector3.new(0.1, 0.6, 0.01), Enum.Material.Neon, Color3.fromRGB(82, 124, 174), 0, fakeChr), CFrame.new(0, 0.5, 0.51)};
[18] = {createPart("bRLL2", Vector3.new(0.1, 0.6, 0.01), Enum.Material.Neon, Color3.fromRGB(82, 124, 174), 0, fakeChr), CFrame.new(0, -0.5, 0.51)}
}
la = createPart("la", Vector3.new(1, 2, 1), Enum.Material.Metal, Color3.fromRGB(163, 162, 165), 0, fakeChr)
ra = createPart("ra", Vector3.new(1, 2, 1), Enum.Material.Metal, Color3.fromRGB(163, 162, 165), 0, fakeChr)
ll = createPart("ll", Vector3.new(1, 2, 1), Enum.Material.Metal, Color3.fromRGB(33, 84, 185), 0, fakeChr)
rl = createPart("rl", Vector3.new(1, 2, 1), Enum.Material.Metal, Color3.fromRGB(33, 84, 185), 0, fakeChr)
blaster = createPart("b", Vector3.new(1, 1, 3), Enum.Material.Neon, Color3.fromRGB(151, 0, 0), 0, fakeChr)
local blasterMesh = Instance.new("SpecialMesh")
blasterMesh.MeshId = "rbxassetid://14754571597"
blasterMesh.Parent = blaster
sword = createPart("s", Vector3.new(0.2, 4, 1), Enum.Material.Neon, Color3.fromRGB(255, 89, 89), 0, fakeChr)
shield = createPart("sh", Vector3.new(2, 2, 1), Enum.Material.Neon, Color3.fromRGB(163, 162, 165), 0, fakeChr)
le = createPart("le", Vector3.new(0.125, 0.375, 0.05), Enum.Material.Neon, Color3.new(), 1, fakeChr)
re = createPart("re", Vector3.new(0.125, 0.375, 0.05), Enum.Material.Neon, Color3.new(), 1, fakeChr)
local leTexture = Instance.new("Decal")
leTexture.Texture = "rbxasset://textures/CollisionGroupsEditor/unchecked.png"
leTexture.Color3 = Color3.new(0, 0, 0)
leTexture.Parent = le
local reTexture = leTexture:Clone()
reTexture.Parent = re
nk = weld.new(torso, head, CFrame.new(0, 1, 0), CFrame.new(0, -0.5, 0))
rj = weld.new(root, torso, CFrame.new(0, 0, 0), CFrame.new(0, 0, 0))
ls = weld.new(torso, la, CFrame.new(-1.5, 0.5, 0), CFrame.new(0, 0.5, 0))
rs = weld.new(torso, ra, CFrame.new(1.5, 0.5, 0), CFrame.new(0, 0.5, 0))
lh = weld.new(torso, ll, CFrame.new(-0.5, -1, 0), CFrame.new(0, 1, 0))
rh = weld.new(torso, rl, CFrame.new(0.5, -1, 0), CFrame.new(0, 1, 0))
nkc0 = nk.c0
rjc0 = rj.c0
lsc0 = ls.c0
rsc0 = rs.c0
lhc0 = lh.c0
rhc0 = rh.c0
for _, t in pairs(soundTable) do
for _, v in pairs(t) do
v.Parent = root
end
end
local connTable = {}
for _, p in pairs(script:GetDescendants()) do
if p:IsA("BasePart") then
local conn; conn = p:GetPropertyChangedSignal("Parent"):Connect(function()
if parent == nil then
refit = true
for _, c in pairs(connTable) do
c:Disconnect()
end
end
end)
table.insert(connTable, conn)
end
end
end
createChr()
local blastBullets = {}
local function blast()
local blastBullet = Instance.new("Part")
blastBullet.Size = Vector3.new(0.5, 0.5, 2)
blastBullet.Anchored = true
blastBullet.Color = Color3.fromRGB(82, 124, 174)
blastBullet.Parent = script
blastBullet.CFrame = root.CFrame * CFrame.new(1.5, 1.5, -2)
blastBullet.Material = blaster.Material
table.insert(blastBullets, blastBullet)
game:GetService("Debris"):AddItem(blastBullet, 15)
sounds["ShootSound"]()
end
local t = 0
local speed = 1
local waterSpeedMult = 0.5
local fallTime = 0
local gravity = 196.2
local translateVector = Vector3.new()
local mouseCF = CFrame.new()
local floor = false
local faceMouse = false
local currentCF = CFrame.new()
local vel = Vector3.new()
local lastShot = os.clock()
local lastSwing = os.clock()
local lastHit = os.clock()
local blink = false
local currentWeapon = ""
local weaponEquip = false
local blastCharge = true
game:GetService("RunService").PostSimulation:Connect(function(dt)
t += dt * 60
if script then
if hum.Jump and floor then
fallTime = -0.3
end
previousCF = root.Position
rj:Enforce()
nk:Enforce()
ls:Enforce()
rs:Enforce()
lh:Enforce()
rh:Enforce()
local dy = Vector3.yAxis * dt * ((-gravity / 2) * dt - gravity * fallTime)
if hum.MoveDirection.Magnitude > 0.5 then
if not faceMouse then
root.CFrame = CFrame.lookAt(root.Position, root.Position + hum.MoveDirection) + (hum.MoveDirection / 3) * speed
end
end
local rayBottom = workspace:Blockcast(root.CFrame, root.Size, -Vector3.yAxis * 2 + dy, raycastParams)
if rayBottom then
local hit, pos = rayBottom.Instance, rayBottom.Position
fallTime = 0
floor = true
root.Position = Vector3.new(root.Position.X, pos.Y + 3, root.Position.Z)
if hit.Velocity.Magnitude > 0 then
root.Position += hit.Velocity / 60
end
else
floor = false
root.Position += dy
end
local rayTop = workspace:Blockcast(root.CFrame, root.Size, root.CFrame.UpVector * 1.5, raycastParams)
if rayTop then
fallTime = 0
end
fallTime += dt
local raySide = workspace:Blockcast(root.CFrame, root.Size, root.CFrame.LookVector.Unit, raycastParams)
if raySide and raySide.Instance.CanCollide then
local hit, pos, norm = raySide.Instance, raySide.Position, raySide.Normal
--translateVector -= norm * norm:Dot(translateVector)
root.CFrame -= norm * norm:Dot(root.CFrame.LookVector)
end
if faceMouse then
root.CFrame = CFrame.lookAt(root.Position, mouseCF.p * Vector3.new(1, 0, 1))
end
if root.CFrame.Y < -100 then
root.CFrame = CFrame.new(0, 15, 0)
fallTime = 0
end
vel = root.Position - previousCF
if vel.Y > 50 then
fallTime = 0
root.CFrame = CFrame.new(0, 15, 0)
end
do -- animations
if vel.Y ~= 0 then
speed = math.clamp(speed + 0.01, 1, 3)
rj.c0 = rj.c0:Lerp(rjc0 * CFrame.Angles(-vel.Y / 10, 0, 0), 0.3 * dt * 60)
nk.c0 = nk.c0:Lerp(nkc0, 0.3 * dt * 60)
ls.c0 = ls.c0:Lerp(lsc0 * CFrame.Angles(math.rad(120) - vel.Y / 2, -math.rad(5), -math.rad(3)), 0.3 * dt * 60)
if weaponEquip == true then
rs.c0 = rs.c0:Lerp(rsc0 * CFrame.new(0, 0, -0.05) * CFrame.Angles(math.rad(90), 0, 0), 0.3 * dt * 60)
elseif weaponEquip == false then
rs.c0 = rs.c0:Lerp(rsc0 * CFrame.new(0, 0, 0.15) * CFrame.Angles(-math.rad(65), 0, 0), 0.3 * dt * 60)
end
lh.c0 = lh.c0:Lerp(lhc0 * CFrame.new(0, vel.Y / 1.5, -0.5 + vel.Y / 3) * CFrame.Angles(math.rad(30) - vel.Y / 3, math.rad(5) - vel.Y / 15, -math.rad(3) + vel.Y / 15), 0.3 * dt * 60)
rh.c0 = rh.c0:Lerp(rhc0 * CFrame.new(0, vel.Y / 3, 0 - vel.Y / 3) * CFrame.Angles(-math.rad(85) + vel.Y / 5, -math.rad(5) + vel.Y / 15, math.rad(3) - vel.Y / 15), 0.3 * dt * 60)
else
speed = 1
if hum.MoveDirection.Magnitude > 0.5 then
rj.c0 = rj.c0:Lerp(rjc0 * CFrame.new(0, math.sin(t / 2.5 * speed) / 10, 0) * CFrame.Angles(-math.cos(t / 2.5 * speed) / 40, 0, 0), 0.3 * dt * 60)
nk.c0 = nk.c0:Lerp(nkc0 * CFrame.Angles(-math.cos(t / 2.5 * speed) / 40, 0, 0), 0.3 * dt * 60)
ls.c0 = ls.c0:Lerp(lsc0 * CFrame.new(-0.1, -math.cos(t / 2.5 * speed) / 7.5, -0.05) * CFrame.Angles(-math.sin(t / 5 * speed), math.rad(3), -math.rad(5)), 0.3 * dt * 60)
if weaponEquip == true then
rs.c0 = rs.c0:Lerp(rsc0 * CFrame.new(0, -math.cos(t / 2.5 * speed) / 7.5, -0.05) * CFrame.Angles(math.rad(90) + -math.cos(t / 2.5 * speed) / 50, 0, 0), 0.3 * dt * 60)
elseif weaponEquip == false then
rs.c0 = rs.c0:Lerp(rsc0 * CFrame.new(0.1, -math.cos(t / 2.5 * speed) / 7.5, -0.05) * CFrame.Angles(math.sin(t / 5 * speed), -math.rad(5), math.rad(7)), 0.3 * dt * 60)
end
lh.c0 = lh.c0:Lerp(lhc0 * CFrame.new(0, 0.25 + math.cos(t / 5 * speed) / 3, -0.125 - math.cos(t / 5 * speed) / 6) * CFrame.Angles(-math.rad(8) + math.sin(t / 5 * speed), math.rad(9), -math.rad(7)), 0.3 * dt * 60)
rh.c0 = rh.c0:Lerp(rhc0 * CFrame.new(0, 0.25 - math.cos(t / 5 * speed) / 3, -0.125 + math.cos(t / 5 * speed) / 6) * CFrame.Angles(-math.rad(8) - math.sin(t / 5 * speed), -math.rad(7), math.rad(9)), 0.3 * dt * 60)
else
rj.c0 = rj.c0:Lerp(rjc0, 0.3 * dt * 60)
nk.c0 = nk.c0:Lerp(nkc0, 0.3 * dt * 60)
ls.c0 = ls.c0:Lerp(lsc0 * CFrame.new(0, 0, -0.05) * CFrame.Angles(-math.cos(t / 40) / 40, math.rad(3), -math.rad(5) + math.sin(t / 40) / 40), 0.3 * dt * 60)
if weaponEquip == true then
rs.c0 = rs.c0:Lerp(rsc0 * CFrame.new(0, 0, -0.05) * CFrame.Angles(math.rad(90), 0, 0), 0.3 * dt * 60)
elseif weaponEquip == false then
rs.c0 = rs.c0:Lerp(rsc0 * CFrame.new(0, 0, -0.05) * CFrame.Angles(math.cos(t / 40) / 40, -math.rad(5), math.rad(7) - math.sin(t / 40) / 40), 0.3 * dt * 60)
end
lh.c0 = lh.c0:Lerp(lhc0 * CFrame.Angles(0, math.rad(9), -math.rad(7)), 0.3 * dt * 60)
rh.c0 = rh.c0:Lerp(rhc0 * CFrame.Angles(0, -math.rad(7), math.rad(9)), 0.3 * dt * 60)
end
end
end
cam.CFrame = root.CFrame * CFrame.new(0, 1.5, 0)
for i, l in ipairs(lights) do
if i <= 6 then
l[1].CFrame = torso.CFrame * lights[i][2]
elseif i > 6 and i <= 12 then
l[1].CFrame = ll.CFrame * lights[i][2]
elseif i > 12 and i <= 18 then
l[1].CFrame = rl.CFrame * lights[i][2]
end
end
if weaponEquip == true then
if currentWeapon == "blaster" then
blaster.CFrame = ra.CFrame * CFrame.new(0, -1.5, -1) * CFrame.Angles(-math.rad(90), math.rad(90), 0)
sword.CFrame = torso.CFrame * CFrame.new(-1.1, -1, 0) * CFrame.Angles(-math.rad(85), 0, 0)
shield.CFrame = torso.CFrame * CFrame.new(0, 0, 1) * CFrame.Angles(0, 0, -math.rad(35))
elseif currentWeapon == "sword" and weaponEquip == true then
blaster.CFrame = torso.CFrame * CFrame.new(1, 1.5, 0) * CFrame.Angles(0, math.rad(90), 0)
if (os.clock() - lastSwing) < 0.25 then
sword.CFrame = ra.CFrame * CFrame.new(0, -3, 0.125) * CFrame.Angles(math.rad(180), 0, 0)
local swingHitbox = workspace:GetPartBoundsInBox(sword.CFrame, sword.Size, overlapParams)
for _, p in pairs(swingHitbox) do
local hurtHums = {}
if p.Parent:FindFirstChild("Humanoid") then
local hurtHum = p.Parent:FindFirstChild("Humanoid")
if table.find(hurtHums, hurtHum) == nil then
hurtHum:TakeDamage(hurtHum.MaxHealth / 4)
table.insert(hurtHum)
end
end
end
else
sword.CFrame = ra.CFrame * CFrame.new(0, -2, -1) * CFrame.Angles(math.rad(55), 0, 0)
end
shield.CFrame = torso.CFrame * CFrame.new(0, 0, 1) * CFrame.Angles(0, 0, -math.rad(35))
elseif currentWeapon == "shield" and weaponEquip == true then
blaster.CFrame = torso.CFrame * CFrame.new(1, 1.5, 0) * CFrame.Angles(0, math.rad(90), 0)
sword.CFrame = torso.CFrame * CFrame.new(-1.1, -1, 0) * CFrame.Angles(-math.rad(85), 0, 0)
shield.CFrame = ra.CFrame * CFrame.new(0, -1.5, 0) * CFrame.Angles(math.rad(90), 0, 0)
end
if shooting == true then
if currentWeapon == "blaster" then
if (os.clock() - lastShot) > 0.3 then
lastShot = os.clock()
blast()
end
elseif currentWeapon == "sword" then
if (os.clock() - lastSwing) > 0.5 then
lastSwing = os.clock()
end
elseif currentWeapon == "shield" then
if (os.clock() - lastHit) > 0.5 then
lastHit = os.clock()
shieldHit()
end
end
end
elseif weaponEquip == false then
blaster.CFrame = torso.CFrame * CFrame.new(1, 1.5, 0) * CFrame.Angles(0, math.rad(90), 0)
sword.CFrame = torso.CFrame * CFrame.new(-1.1, -1, 0) * CFrame.Angles(-math.rad(85), 0, 0)
shield.CFrame = torso.CFrame * CFrame.new(0, 0, 1) * CFrame.Angles(0, 0, -math.rad(35))
end
if random:NextInteger(1, 100) == 50 then
task.spawn(function()
blink = true
task.wait(0.1)
blink = false
end)
end
if blink == true then
le.CFrame = head.CFrame * CFrame.new(-0.25, 0.0625, -0.5)
re.CFrame = head.CFrame * CFrame.new(0.25, 0.0625, -0.5)
le.Size = Vector3.new(0.25, 0.125, 0.05)
re.Size = Vector3.new(0.25, 0.125, 0.05)
else
le.CFrame = head.CFrame * CFrame.new(-0.1875, 0.1875, -0.5)
re.CFrame = head.CFrame * CFrame.new(0.1875, 0.1875, -0.5)
le.Size = Vector3.new(0.125, 0.375, 0.05)
re.Size = Vector3.new(0.125, 0.375, 0.05)
end
for _, bullet in pairs(blastBullets) do
if bullet then
local result = workspace:Raycast(bullet.Position, bullet.CFrame.LookVector * 10, raycastParams)
if result then
local hurtChr = result.Instance:FindFirstAncestorWhichIsA("Model")
if hurtChr and hurtChr:FindFirstChildWhichIsA("Humanoid") and blastCharge == false then
local hHum = hurtChr:FindFirstChildWhichIsA("Humanoid")
hHum:TakeDamage(hHum.MaxHealth / 4)
elseif blastCharge == true then
blastCharge = false
local explosion = Instance.new("Part")
explosion.Color = bullet.Color
explosion.Transparency = 0.125
explosion.Size = Vector3.new(15, 15, 15)
explosion.Shape = Enum.PartType.Ball
explosion.Material = Enum.Material.Neon
explosion.Anchored = true
explosion.Locked = true
explosion.CanCollide = false
explosion.CFrame = bullet.CFrame
explosion.Parent = script
local expTween = game:GetService("TweenService"):Create(
explosion,
TweenInfo.new(2, Enum.EasingStyle.Exponential),
{Transparency = 1, Size = Vector3.new(30, 30, 30)}
):Play()
for _, v in pairs(workspace:GetChildren()) do
if v:FindFirstChild("Humanoid") then
local hurtRoot = v:FindFirstChild("HumanoidRootPart")
local hurtHum = v:FindFirstChild("Humanoid")
if (explosion.Position - hurtRoot.Position).Magnitude < 15 then
v:BreakJoints()
for _, hurtChr in pairs(v:GetDescendants()) do
if hurtChr:IsA("BasePart") then
local att = Instance.new("Attachment")
att.Parent = hurtChr
local linearVel = Instance.new("LinearVelocity")
linearVel.MaxForce = 9e9
linearVel.VectorVelocity = Vector3.new(Random.new():NextNumber(-100, 100), Random.new():NextNumber(-100, 100), Random.new():NextNumber(-100, 100))
linearVel.Attachment0 = att
linearVel.Parent = hurtChr
game:GetService("Debris"):AddItem(linearVel, 0.2)
end
end
end
end
end
game:GetService("Debris"):AddItem(explosion, 5)
end
table.remove(blastBullets, _)
bullet:Destroy()
end
end
bullet.CFrame *= CFrame.new(0, -0.01, -10) * CFrame.Angles(-0.005, 0, 0)
end
if (os.clock() - lastShot) > 2 then
blastCharge = true
end
if (os.clock() - lastHit) > 2 then
shieldCharge = true
end
if blastCharge == false then
blaster.Material = Enum.Material.Metal
else
blaster.Material = Enum.Material.Neon
end
if shieldCharge == false then
shield.Material = Enum.Material.Metal
else
shield.Material = Enum.Material.Neon
end
if refit == true then
for _, p in pairs(script:GetDescendants()) do
if p:IsA("BasePart") then
p:Destroy()
end
end
createChr()
refit = false
end
end
end)
local remote = Instance.new("RemoteEvent")
remote.Name = "KeybindConnection"
remote.Parent = owner.PlayerGui
NLS([[local s = workspace:FindFirstChild("fakeChrModel" .. owner.Name)
local fc = workspace:FindFirstChild("fakeChr" .. owner.Name)
local remote = script.Parent:WaitForChild("KeybindConnection")
local UIS = game:GetService("UserInputService")
workspace.CurrentCamera.CameraSubject = s:WaitForChild("c")
s.DescendantAdded:Connect(function(ch)
if ch.Name == "c" then
workspace.CurrentCamera.CameraSubject = ch
end
end)
UIS.InputBegan:connect(function(key, g)
if not g then
if key.UserInputType == Enum.UserInputType.MouseButton1 then
remote:FireServer("mouse1", "keydown")
elseif key.UserInputType == Enum.UserInputType.Keyboard then
remote:FireServer(key.KeyCode, "keydown")
end
end
end)
UIS.InputEnded:connect(function(key, g)
if not g then
if key.UserInputType == Enum.UserInputType.MouseButton1 then
remote:FireServer("mouse1", "keyup")
elseif key.UserInputType == Enum.UserInputType.Keyboard then
remote:FireServer(key.KeyCode, "keyup")
end
end
end)]], owner.PlayerGui)
remote.OnServerEvent:Connect(function(plr, key, input)
if input == "keydown" then
if key == Enum.KeyCode.Q then
if weaponEquip == true and currentWeapon == "blaster" then
weaponEquip = false
else
currentWeapon = "blaster"
weaponEquip = true
end
elseif key == Enum.KeyCode.E then
if weaponEquip == true and currentWeapon == "sword" then
weaponEquip = false
else
currentWeapon = "sword"
weaponEquip = true
end
elseif key == Enum.KeyCode.R then
if weeaponEquip == true and currentWeapon == "shield" then
weaponEquip = false
else
currentWeapon = "shield"
weaponEquip = true
end
elseif key == Enum.KeyCode.T and songPlaying == false then
weaponEquip = false
sounds["PlaySong"](idleSong)
elseif key == "mouse1" then
shooting = true
end
elseif input == "keyup" then
if key == "mouse1" then
shooting = false
end
end
end)