So I have a shield script that I modified to work in r15, but since I don't know much about hot keybinds work I thought it would be fine if I did not change them, but since they don't work I'm looking for plenty of help on how keybinds work and how I could fix the keybind issue.
-------------[|Script|]----------------
wait(.1)
Player = game.Players.LocalPlayer
Character = Player.Character
LeftHand = Character:FindFirstChild("LeftHand")
UpperTorso = Character:FindFirstChild("UpperTorso")
UpperLeftArm = UpperTorso:FindFirstChild("UpperLeftArm")
ShieldTemplate = script:WaitForChild("ShieldTemplate")
VariantShield = script:WaitForChild("VariantShield")
RemoveFunction = script:WaitForChild("RemoveShield")
Use = false
DataY = 0
Up = false
Down = false
Busy = false
AnimationSpeed = 10 -- Slower, smoother with more integers
ShieldLink = nil
Weld = nil
LeftShoulderMotor = nil
local function WeldDecoration(Variant, WeldTo)
local g = Variant:Clone()
g.Parent = WeldTo.Parent
local C = g:GetChildren()
for i = 1, #C do
if C[i]:IsA("BasePart") then
C[i].CanCollide = true
local W = Instance.new("Weld")
W.Part0 = g.Middle
W.Part1 = C[i]
local CJ = CFrame.new(g.Middle.Position)
local C0 = g.Middle.CFrame:inverse()*CJ
local C1 = C[i].CFrame:inverse()*CJ
W.C0 = C0
W.C1 = C1
W.Parent = g.Middle
end
local Y = Instance.new("Weld")
Y.Part0 = WeldTo
Y.Part1 = g.Middle
Y.C0 = CFrame.new(0, 0, 0)
Y.Parent = Y.Part0
end
local h = g:GetChildren()
for i = 1, # h do
h[i].Anchored = false
h[i].CanCollide = false
end
end
local function CreateShield()
local Shield = ShieldTemplate:Clone()
Shield.Name = "Shield"
Shield.Parent = Character
WeldDecoration(VariantShield, Shield.Handle)
Shield:MoveTo(Character.UpperTorso.Position)
ShieldWeld = Instance.new("Weld", Shield)
ShieldWeld.Part0 = LeftHand
ShieldWeld.Part1 = Shield.Handle
local ShieldTag = Instance.new("StringValue", Shield.Handle)
ShieldTag.Name = "IsShield"
ShieldTag.Value = "Wood"
ShieldWeld.C0 = CFrame.new(-0.175, -0.1, 0) * CFrame.fromEulerAnglesXYZ(math.rad(90),math.rad(90), 0)
ShieldLink = Shield
end
function CommandIssued(Type, Data)
if Type == "KeyPress" and Data ~= nil then
local Key = Data:lower()
if Key == "r" then
if not Use and not Busy then
Busy = true
if not Character:FindFirstChild("Shield") then
CreateShield()
end
LeftShoulderMotor = UpperTorso["UpperLeftArm"].C1 -- Save data
UpperLeftArm.Part1 = nil -- Disconnect arm from shoulder
Weld = Instance.new("Weld") -- New Weld LeftArm to Torso
Weld.Name = "LeftHand Weld"
Weld.Part0 = UpperTorso
Weld.Part1 = LeftHand
Weld.Parent = UpperTorso
Weld.C0 = CFrame.new(-1.5,0,0) -- Reposition arm
for i = 1,AnimationSpeed do
Weld.C0 = Weld.C0 * CFrame.new(0.5/AnimationSpeed,-0.25/AnimationSpeed,-1/AnimationSpeed)*CFrame.fromEulerAnglesXYZ(math.rad(70/AnimationSpeed),math.rad(-40/AnimationSpeed),math.rad(40/AnimationSpeed)) -- if you tweak the numbers long enough you manage to get a smooth animation, sometimes it takes really long until you finally get all the positions right but when it comes to cframe/Weld manipulation the best way to achieve the wanted formula is trough trial and error
wait()
end
Busy = false
Use = true
else
if not Busy then
Busy = true
if DataY > 0 then
for i = 1, DataY do
DataY = DataY - 1
Weld.C0 = Weld.C0 * CFrame.new(0,0,0.04)*CFrame.fromEulerAnglesXYZ(math.rad(-3),math.rad(1),math.rad(0))
if ShieldWeld ~= nil then
ShieldWeld.C0 = ShieldWeld.C0 * CFrame.new(.02, 0, .015) * CFrame.fromEulerAnglesXYZ(math.rad(.9), math.rad(-2), math.rad(.75)) -- SHIELD WELD HERE
end
wait()
end
end
for i = 1, AnimationSpeed do
Weld.C0 = Weld.C0*CFrame.new(-0.5/AnimationSpeed,0.25/AnimationSpeed,1/AnimationSpeed)*CFrame.fromEulerAnglesXYZ(math.rad(-70/AnimationSpeed),math.rad(40/AnimationSpeed),math.rad(-40/AnimationSpeed)) -- the equiping animation reversed
wait()
end
ShieldWeld.C0 = CFrame.new(-0.175, -0.1, 0) * CFrame.fromEulerAnglesXYZ(math.rad(90),math.rad(90), 0)
Weld:Destroy()
UpperLeftArm.Part1 = LeftHand
UpperLeftArm.C1 = LeftShoulderMotor
DataY = 0
Use = false
Busy = false
end
end
elseif Key == "r" then
if Up == false and Down == false and Use == true and Busy == false then
Up = true
while Up == true and DataY < 30 do
DataY = DataY + 1
Weld.C0 = Weld.C0 * CFrame.new(0, 0, -0.04) * CFrame.fromEulerAnglesXYZ(math.rad(3),math.rad(-1),math.rad(0))
if ShieldWeld ~= nil then
ShieldWeld.C0 = ShieldWeld.C0 * CFrame.new(-.02, 0, -.015) * CFrame.fromEulerAnglesXYZ(math.rad(-.9), math.rad(2), math.rad(-.75)) -- SHIELD WELD HERE
end
wait()
end
end
elseif Key == "t" then
if Down == false and Up == false and Use == true and Busy == false then
Down = true
while Down == true and DataY > 0 do
DataY = DataY-1
Weld.C0 = Weld.C0 * CFrame.new(0, 0, 0.04) * CFrame.fromEulerAnglesXYZ(math.rad(-3),math.rad(1),math.rad(0))
if ShieldWeld ~= nil then
ShieldWeld.C0 = ShieldWeld.C0 * CFrame.new(.02, 0, .015) * CFrame.fromEulerAnglesXYZ(math.rad(.9), math.rad(-2), math.rad(.75)) -- SHIELD WELD HERE
end
wait()
end
end
end
elseif Type == "Remove" then
if Weld then
Weld:Destroy()
end
UpperLeftArm.Part1 = LeftHand
if ShieldLink then
ShieldLink:Destroy()
end
end
end
function CommandStopped(Key)
Key = Key:lower()
if Key == "i" then
Up = false
elseif Key == "u" then
Down = false
end
end
function RemoveFunction.OnClientInvoke()
CommandIssued("Remove")
end
CreateShield()
Player:GetMouse().KeyDown:connect(function(Key)
CommandIssued("KeyPress", Key)
end)
Player:GetMouse().KeyUp:connect(CommandStopped)
----[|Scripts Children|]----
A remote function named "RemoveShield" A model named "ShieldTemplate" A model named "VariantShield"

5 comments
Under code 07 you can add any function you would like other than a brick color changing
It seems like it wont work I think it might be because two main models for how the shield will look are not referenced, and I forgot to say the Shield its self is a model that with the original script it would be on the players arm.
It seems like it wont work I think it might be because two main models for how the shield will look are not referenced, and I forgot to say the Shield its self is a model that with the original script it would be on the players arm.
It seems like it wont work I think it might be because two main models for how the shield will look are not referenced, and I forgot to say the Shield its self is a model that with the original script it would be on the players arm.
If you can make a video link to your problem to help me better understand that would be appreciated