So I have a skill called UltraShield, it should create a giant armor around the player in the shape of the player, like that:
I tried clone all player parts, increase the size and try make position that, but dont work very well
**The head be a CUBIC for any reason, **
the parts behave very strange when the player walks, can someone help me?
That is the code:
--//Services
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local ServerStorage = game:GetService("ServerStorage")
local Players = game:GetService("Players")
--//Modules
local Casting = require(game:GetService("ServerStorage").Modules.CheckCastingSkill)
local CheckSkill = require(ServerStorage.Modules.CheckCanSkill)
local Shield = require(game:GetService("ServerStorage").Modules.Shields)
local LerpAP = require(game:GetService("ReplicatedStorage").Modules.LerpAPI)
local Effects = require(ServerStorage.Modules.Effects)
local Skills = require(script.Parent.Parent.Script.Skills)
local DamageManager = require(ServerStorage.Modules.DamageManager)
local Unstoppable = require(ServerStorage.GoodEffects.Unstoppable)
local Metrics = {
["LeftFoot"] = Vector3.new(-0.8999999999999915,-5.49,0),
["LeftHand"] = Vector3.new(-2.7,-1.9,0),
["LeftLowerArm"] = Vector3.new(-2.7,-0.8,0),
["LeftLowerLeg"] = Vector3.new(-0.9,-4.3,0),
["LeftUpperArm"] = Vector3.new(-2.7,0.3,0),
["LeftUpperLeg"] = Vector3.new(-0.9,-2.9,0),
["LowerTorso"] = Vector3.new(0,-1.8,0),
["RightFoot"] = Vector3.new(0.9000000000000057,-5.5,0),
["RightHand"] = Vector3.new(2.700000000000003,-1.9,0),
["RightLowerArm"] = Vector3.new(2.700000000000003,-0.8,0),
["RightLowerLeg"] = Vector3.new(0.9000000000000057,-4.3,0),
["RightUpperArm"] = Vector3.new(2.700000000000003,0.3,0),
["RightUpperLeg"] = Vector3.new(0.9000000000000057,-2.9,0),
["UpperTorso"] = Vector3.new(0,0,0),
["Head"] = Vector3.new(0,2.3,0)
}
local UltraS = {}
UltraS.__index = UltraS
function UltraS.New(player,T,D,slot,Stage,cd)
if Stage == 2 then
Casting.RemoveCast(player.UserId,0)
Skills.Cooldown(player,0,"UltraShield",slot)
else
local newUltra = {}
setmetatable(newUltra,UltraS)
newUltra.Name = "UltraShield"
newUltra.Stage = 1
newUltra.OldCharacter = Instance.new("Folder",ServerStorage)
newUltra.Slot = slot
newUltra.Player = player
newUltra.OldCharacter.Name = newUltra.Player.Name
newUltra.Model = ReplicatedStorage.Skills.Elemental.UltraShield.Meshes.Model:Clone()
newUltra.Model.Name = player.Name.." UltraShield"
newUltra.Model.Parent = workspace
newUltra.Cooldown = cd
return newUltra
end
end
function UltraS:GetVectorFromCFrame(cf)
local VectorC = Vector3.new(cf.X,cf.Y,cf.Z)
return VectorC
end
function UltraS:Build()
if self.Stage == 2 then
for i,v in pairs(self.Player.Character:GetChildren()) do
if v:IsA("MeshPart")then
if v.Name~='HumanoidRootPart' then
local Clone = v:Clone()
Clone:ClearAllChildren()
Clone.Parent = workspace
Clone.Anchored = false
Clone.CanCollide = false
Clone.CastShadow = false
Clone.Transparency = 0.8
Clone.Material = Enum.Material.Neon
local Weld = Instance.new("Weld",self.Model)
Weld.Part0 = Clone
Weld.Part1 = v
Clone.Size = Clone.Size * Vector3.new(2.8,2.8,2.8)
Clone.Position = v.Position + Metrics[""..v.Name]
end
elseif v.Name == "Head" then
local Clone = v:Clone()
Clone:ClearAllChildren()
Clone.Parent = workspace
Clone.Anchored = false
Clone.CanCollide = false
Clone.CastShadow = false
Clone.Transparency = 0.8
Clone.Material = Enum.Material.Neon
local Weld = Instance.new("Weld",self.Model)
Weld.Part0 = Clone
Weld.Part1 = v
Clone.Size = Clone.Size * Vector3.new(2.8,2.8,2.8)
Clone.Position = v.Position + Metrics[""..v.Name]
end
end
self.Player.Character:WaitForChild("Humanoid").HipHeight = 8
elseif self.Stage == 0 then
end
end
--[[
function UltraS:Build()
if self.Stage == 2 then
for i,v in pairs(self.Player.Character:GetChildren()) do
if v:IsA("MeshPart")then
if v.Name~='HumanoidRootPart' and v.Name~='Head' then
if v.Name == "LeftUpperArm" then
local Clone = v:Clone()
Clone.Parent = self.Model
Clone:ClearAllChildren()
if v.Name == "LeftHand" or v.Name == "RightHand" or v.Name =="RightFoot" or v.Name == "LeftFoot" then
print("SERIUS? REALLUW")
local Trail = self.Model.Trail:Clone()
local Att = {Instance.new("Attachment",Clone),Instance.new("Attachment",Clone)}
Att[2].Position = Vector3.new(0,2.8,0)
Trail.Parent = self.Model
Trail.Attachment0 = Att[1]
Trail.Attachment1 = Att[2]
end
Clone.Transparency = 0.9
Clone.Size = Vector3.new(2.8, 3.272, 2.8)
Clone.BrickColor = BrickColor.new("White")
Clone.Anchored = false
Clone.CastShadow = false
Clone.CanCollide = false
Clone.Material = Enum.Material.Neon
local Weld = Instance.new("Weld",self.Model)
Weld.Part0 = Clone
Weld.Part1 = v
Clone.Position = Clone.Position + Vector3.new(10,10,10)
end
end
end
end
elseif self.Stage == 0 then
for i,v in pairs(self.Model:GetChildren()) do
if v:IsA("MeshPart") then
coroutine.wrap(function()
local Actual = v.Size
for i = 0, 1, 1/30 do
v.Transparency = LerpAP.Lerp(v.Transparency,0.8,i)
v.Size = LerpAP.Lerp(v.Size,Actual - Vector3.new(9.5,9.5,9.5),i)
--v.CFrame = CFrame.new(LerpAP.Lerp(self:GetVectorFromCFrame(v.CFrame),self.Player.Character:WaitForChild(""..v.Name).Position,i))
RunService.Heartbeat:Wait()
end
end)()
end
end
end
end
--]]
function UltraS:CreateEffects()
if self.Stage == 1 then
self.Stage = 2
coroutine.wrap(function()
for i = 0, 1, 1/30 do
self.Player.Character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(LerpAP.Lerp(self:GetVectorFromCFrame(self.Player.Character:WaitForChild("HumanoidRootPart").CFrame),Vector3.new(self.Player.Character:WaitForChild("HumanoidRootPart").CFrame.X,self.Player.Character:WaitForChild("HumanoidRootPart").CFrame.Y + 8, self.Player.Character:WaitForChild("HumanoidRootPart").CFrame.Z),i))
RunService.Heartbeat:Wait()
end
end)()
self:Build()
elseif self.Stage == 2 then
self.Stage = 0
--self:Build()
end
end
function UltraS:CanFire()
if self.Stage == 1 then
self:CreateEffects()
elseif self.Stage == 2 then
self:CreateEffects()
end
end
return UltraS