local chr = owner.Character
local shooting = false
local equipped = false
chr:FindFirstChildWhichIsA("Humanoid"):UnequipTools()
function createObject(obj, ...)
local object = Instance.new(obj)
local par = nil
for i, v in next, (...) do
if tostring(i) ~= "Parent" then
object[i] = v
else
par = v
end
end
if par ~= nil then
object.Parent = par
end
return object
end
local rigt = createObject("Tool", {Name = "Rainbow Infinite Gun", ToolTip = "Now with Moksi Switch Up!", CanBeDropped = true, Parent = owner.Backpack})
script.Parent = rigt
local rigtHandle = createObject("Part", {Name = "Handle", Transparency = 1, Rotation = Vector3.new(0, 0, 90), Parent = rigt})
local rigtModel = Instance.new("Model")
rigtModel.Name = "rigt"
local h1 = createObject("Part", {Material = "ForceField", Size = Vector3.new(0.2, 0.6, 0.2), Massless = true, CanCollide = false, Parent = rigtModel})
local h1w = createObject("Weld", {
Part0 = chr:FindFirstChild("Right Arm") or chr:FindFirstChild("RightLowerArm"),
Part1 = h1,
C0 = CFrame.new(0, -1, 0) * CFrame.Angles(math.rad(90), 0, 0),
C1 = CFrame.new(0, 0.21, 0),
Parent = chr:FindFirstChild("Right Arm") or chr:FindFirstChild("RightLowerArm")
})
local w1 = createObject("Part", {Material = "ForceField", Size = Vector3.new(0.2, 0.5, 0.2), Shape = "Wedge", Massless = true, CanCollide = false, Parent = rigtModel})
local w1w = createObject("Weld", {Part0 = h1, Part1 = w1, C0 = CFrame.new(0, -0.3, 0.2) * CFrame.Angles(0, math.rad(180), 0), Parent = h1})
local w2 = createObject("Part", {Material = "ForceField", Size = Vector3.new(0.2, 0.5, 0.2), Shape = "Wedge", Massless = true, CanCollide = false, Parent = rigtModel})
local w2w = createObject("Weld", {Part0 = h1, Part1 = w2, C0 = CFrame.new(0, -0.4, 0) * CFrame.Angles(0, 0, math.rad(180)), Parent = h1})
local p1 = createObject("Part", {Material = "ForceField", Size = Vector3.new(0.3, 0.3, 0.3), Massless = true, CanCollide = false, Parent = rigtModel})
local p1w = createObject("Weld", {Part0 = h1, Part1 = p1, C0 = CFrame.new(0, -0.5, 0.2), Parent = h1})
local p2 = createObject("Part", {Material = "ForceField", Size = Vector3.new(0.3, 0.5, 0.5), Massless = true, CanCollide = false, Parent = rigtModel})
local p2w = createObject("Weld", {Part0 = h1, Part1 = p2, C0 = CFrame.new(0, -0.6, 0.5), Parent = h1})
local p3 = createObject("Part", {Material = "ForceField", Size = Vector3.new(0.4, 0.4, 0.4), Shape = "Cylinder", Massless = true, CanCollide = false, Parent = rigtModel})
local p3w = createObject("Weld", {Part0 = h1, Part1 = p3, C0 = CFrame.new(0, -0.6, 0.5) * CFrame.Angles(math.rad(90), 0, 0), Parent = h1})
for i = 1, 8 do
local pc = createObject("Part", {Material = "ForceField", Size = Vector3.new(0, 0.35, 0.41), Massless = true, CanCollide = false, Parent = rigtModel})
local pcw = createObject("Weld", {Part0 = p3, Part1 = pc, C0 = CFrame.Angles(0, math.rad((360 / 8) * i), 0), Parent = h1})
end
local p4 = createObject("Part", {Material = "ForceField", Size = Vector3.new(0.38, 0.41, 0.38), Shape = "Cylinder", Massless = true, CanCollide = false, Parent = rigtModel})
local p4w = createObject("Weld", {Part0 = h1, Part1 = p4, C0 = CFrame.new(0, -0.6, 0.5), Parent = h1})
local s1 = createObject("Part", {Material = "ForceField", Size = Vector3.new(0.37, 0.5, 0.37), Shape = "Ball", Massless = true, CanCollide = false, Parent = rigtModel})
local s1w = createObject("Weld", {Part0 = h1, Part1 = s1, C0 = CFrame.new(0, -0.6, 0.3) * CFrame.Angles(math.rad(90), 0, 0), Parent = h1})
local w3 = createObject("Part", {Material = "ForceField", Size = Vector3.new(0.2, 0.7, 0.4), Shape = "Wedge", Massless = true, CanCollide = false, Parent = rigtModel})
local w3w = createObject("Weld", {Part0 = h1, Part1 = w3, C0 = CFrame.new(0, -0.7, 0.5) * CFrame.Angles(math.rad(90), math.rad(90), math.rad(180)), Parent = h1})
local p5 = createObject("Part", {Material = "ForceField", Size = Vector3.new(0.3, 0.4, 0.2), Massless = true, CanCollide = false, Parent = rigtModel})
local p5w = createObject("Weld", {Part0 = h1, Part1 = p5, C0 = CFrame.new(0, -0.6, 0.7), Parent = h1})
local p6 = createObject("Part", {Material = "ForceField", Size = Vector3.new(0.35, 0.35, 0.35), Shape = "Cylinder", Massless = true, CanCollide = false, Parent = rigtModel})
local p6w = createObject("Weld", {Part0 = h1, Part1 = p6, C0 = CFrame.new(0, -0.6, 0.7) * CFrame.Angles(math.rad(90), 0, 0), Parent = h1})
local p7 = createObject("Part", {Material = "ForceField", Size = Vector3.new(0.5, 0.1, 0.5), Shape = "Cylinder", Massless = true, CanCollide = false, Parent = rigtModel})
local p7w = createObject("Weld", {Part0 = h1, Part1 = p7, C0 = CFrame.new(0, -0.6, 1) * CFrame.Angles(math.rad(90), 0, 0), Parent = h1})
local p8 = createObject("Part", {Material = "ForceField", Size = Vector3.new(0.5, 0.1, 0.45), Shape = "Cylinder", Massless = true, CanCollide = false, Parent = rigtModel})
local p8w = createObject("Weld", {Part0 = h1, Part1 = p8, C0 = CFrame.new(0, -0.6, 1.1) * CFrame.Angles(math.rad(90), 0, 0), Parent = h1})
local w3 = createObject("Part", {Material = "ForceField", Size = Vector3.new(0.2, 0.5, 0.2), Shape = "Wedge", Massless = true, CanCollide = false, Parent = rigtModel})
local w3w = createObject("Weld", {Part0 = h1, Part1 = w3, C0 = CFrame.new(0, -0.55, 0.2) * CFrame.Angles(-math.rad(135), 0, 0), C1 = CFrame.new(0, -0.3, 0), Parent = h1})
local p9 = createObject("Part", {Material = "ForceField", Size = Vector3.new(0.1, 0.2, 0), Massless = true, CanCollide = false, Parent = rigtModel})
local p9w = createObject("Weld", {Part0 = h1, Part1 = p9, C0 = CFrame.new(0, -0.1, 0.2) * CFrame.Angles(math.rad(90), 0, 0), Parent = h1})
local lastGunPart = p9
for i = 1, 9 do
local pc = createObject("Part", {Material = "ForceField", Size = Vector3.new(0.1, 0.05, 0), Massless = true, CanCollide = false, Parent = rigtModel})
local pcw = createObject("Weld", {Part0 = lastGunPart, Part1 = pc, C0 = CFrame.new(0, -0.025, 0) * CFrame.Angles(math.rad(8), 0, 0), C1 = CFrame.new(0, -0.025, 0), Parent = h1})
lastGunPart = pc
end
local b1 = createObject("Part", {Material = "ForceField", Size = Vector3.new(0.15, 4, 0.15), Shape = "Cylinder", Massless = true, CanCollide = false, Parent = rigtModel})
local b1w = createObject("Weld", {Part0 = h1, Part1 = b1, C0 = CFrame.new(0, -0.6, 1.85) * CFrame.Angles(math.rad(90), 0, 0), Parent = h1})
local b2 = createObject("Part", {Material = "ForceField", Size = Vector3.new(0.25, 2, 0.25), Shape = "Cylinder", Massless = true, CanCollide = false, Parent = rigtModel})
local b2w = createObject("Weld", {Part0 = b1, Part1 = b2, C0 = CFrame.new(0, -0.2, 0), Parent = h1})
local w4 = createObject("Part", {Material = "ForceField", Size = Vector3.new(0, 0.1, 0.2), Shape = "Wedge", Massless = true, CanCollide = false, Parent = rigtModel})
local w4w = createObject("Weld", {Part0 = b1, Part1 = w4, C0 = CFrame.new(0, 0.945, 0.1) * CFrame.Angles(-math.rad(135), 0, 0), C1 = CFrame.new(0, -0.3, 0), Parent = h1})
local gh = createObject("Part", {Material = "ForceField", Size = Vector3.new(0.125, 0, 0.125), Shape = "Cylinder", Massless = true, CanCollide = false, Parent = rigtModel})
local ghw = createObject("Weld", {Part0 = b1, Part1 = gh, C0 = CFrame.new(0, 2, 0), Parent = h1})
local g1 = createObject("Part", {Material = "ForceField", Size = Vector3.new(), Transparency = 0.5, Massless = true, CanCollide = false, Parent = rigtModel})
local g1w = createObject("Weld", {Part0 = h1, Part1 = g1, C0 = CFrame.new(0, -0.6, 0.7), Parent = h1})
local g1m = createObject("SpecialMesh", {MeshId = "rbxassetid://156292343", Scale = Vector3.new(0.8, 0.8, 1.5), Offset = Vector3.new(0, 0, 0.2), Parent = g1})
local g2 = createObject("Part", {Material = "ForceField", Size = Vector3.new(), Transparency = 0.5, Massless = true, CanCollide = false, Parent = rigtModel})
local g2w = createObject("Weld", {Part0 = h1, Part1 = g2, C0 = CFrame.new(0, -0.6, 0.7), Parent = h1})
local g2m = createObject("SpecialMesh", {MeshId = "rbxassetid://156292343", Scale = Vector3.new(0.9, 0.9, 0.3), Offset = Vector3.new(0, 0, 0.2), Parent = g2})
local firePt = createObject("ParticleEmitter", {
Size = NumberSequence.new(0.1, 0),
VelocitySpread = 360,
Lifetime = NumberRange.new(0.3, 0.5),
Speed = NumberRange.new(0.2),
Transparency = NumberSequence.new({NumberSequenceKeypoint.new(0, 0.3), NumberSequenceKeypoint.new(0.3, 0), NumberSequenceKeypoint.new(1, 1)}),
LightEmission = 0.5,
Rate = 150,
ZOffset = 0.2,
Rotation = NumberRange.new(-180, 180),
RotSpeed = NumberRange.new(-180, 180),
Texture = "http://www.roblox.com/asset/?id=304437537",
Color = ColorSequence.new(Color3.new(1, 0, 0), Color3.new(0.4, 0, 0)),
Acceleration = Vector3.new(0, 5, 0),
Drag = 0,
Parent = gh
})
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.IgnoreWater = true
raycastParams.FilterDescendantsInstances = {rigt, chr}
function shoot(mHit)
if rigtModel.Parent == chr and equipped == true and mHit then
local bSound = createObject("Sound", {SoundId = "rbxassetid://904440937", Volume = 0.25, Parent = rigtHandle})
bSound:Play()
local dir = CFrame.new(gh.Position, mHit).LookVector
local shootRay = workspace:Raycast(gh.Position, dir * 9e9, raycastParams)
local bullet = createObject("Part", {
Material = "Neon",
Anchored = true,
Shape = "Cylinder",
Massless = true,
CanCollide = false,
Transparency = 0.55,
Parent = gh
})
task.spawn(function()
game:GetService("TweenService"):Create(bullet, TweenInfo.new(2), {Transparency = 1}):Play()
end)
game:GetService("Debris"):AddItem(bullet, 2)
local dist = shootRay.Distance
bullet.CFrame = CFrame.lookAt(gh.Position, gh.Position + shootRay.Position) * CFrame.Angles(0, math.rad(90), 0) * CFrame.new(dist / 2, 0, 0)
bullet.Size = Vector3.new(dist, 0.25, 0.25)
if shootRay and shootRay.Instance.Name ~= "Base" then
shootRay.Instance:Destroy()
end
end
end
local mousePoint
local remote = Instance.new("RemoteEvent")
remote.Name = "rigtEvent"
remote.Parent = rigt
NLS([[local remote = script.Parent:FindFirstChild("rigtEvent")
local UIS = game:GetService("UserInputService")
local tool = script.Parent
local cam = workspace.Camera
game:GetService("RunService").RenderStepped:Connect(function()
local mousePos = UIS:GetMouseLocation()
local mousePoint = cam:ScreenPointToRay(mousePos.X, mousePos.Y)
remote:FireServer("mouse", mousePoint)
end)
UIS.InputBegan:connect(function(key, g)
if not g then
remote:FireServer(key.KeyCode, "keydown")
end
end)
UIS.InputEnded:connect(function(key, g)
if not g then
remote:FireServer(key.KeyCode, "keyup")
end
end)]], rigt)
local armColor = Color3.new(0,0,0)
remote.OnServerEvent:Connect(function(plr, key, input)
if key == Enum.KeyCode.E and input == 'keydown' then
shooting = true
elseif key == Enum.KeyCode.E and input == 'keyup' then
shooting = false
elseif key == "mouse" then
local mouseRay = workspace:Raycast(input.Origin, input.Direction * 9e9, raycastParams)
if mouseRay then
mousePoint = mouseRay.Position
end
end
end)
if chr:FindFirstChildWhichIsA("Humanoid").RigType == Enum.HumanoidRigType.R6 then
r15 = false
elseif chr:FindFirstChildWhichIsA("Humanoid").RigType == Enum.HumanoidRigType.R15 then
r15 = true
end
local armColor = chr['Right Arm'].Color or chr['RightUpperArm'].Color
rigt.Equipped:Connect(function()
equipped = true
for _,v in pairs(gh:GetDescendants()) do
if v.Name == 'Bullet' then
v:Destroy()
end
end
rigtModel.Parent = chr
end)
rigt.Unequipped:Connect(function()
equipped = false
for _,v in pairs(gh:GetDescendants()) do
if v.Name == 'Bullet' then
v:Destroy()
end
end
rigtModel.Parent = nil
end)
game:GetService("RunService").PostSimulation:Connect(function()
if shooting == true then
shoot(mousePoint)
end
for _, v in pairs(rigtModel:GetDescendants()) do
if v.ClassName == "Part" then
v.Color = Color3.fromHSV(os.clock() % 1, 1, 1)
end
end
if equipped == true then
if r15 == false then
chr['Right Arm'].Material = "ForceField"
chr['Right Arm'].Color = Color3.fromHSV(os.clock() % 1, 1, 1)
elseif r15 == true then
chr['RightUpperArm'].Material = "ForceField"
chr['RightLowerArm'].Material = "ForceField"
chr['RightHand'].Material = "ForceField"
chr['RightUpperArm'].Color = Color3.fromHSV(os.clock() % 1, 1, 1)
chr['RightLowerArm'].Color = Color3.fromHSV(os.clock() % 1, 1, 1)
chr['RightHand'].Color = Color3.fromHSV(os.clock() % 1, 1, 1)
end
else
if r15 == false then
chr['Right Arm'].Material = "Plastic"
chr['Right Arm'].Color = armColor
elseif r15 == true then
chr['RightUpperArm'].Material = "Plastic"
chr['RightLowerArm'].Material = "Plastic"
chr['RightHand'].Material = "Plastic"
chr['RightUpperArm'].Color = armColor
chr['RightLowerArm'].Color = armColor
chr['RightHand'].Color = armColor
end
end
end)