Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

How do I script a shield? [closed]

Asked by 9 years ago

Like a script for one of those shields where you press "e" and then "d" and "f" to lower it, spent 3 hours attempting this. The script used is too long to fit in this post, can you help with the basics so far?:

function shieldUp(guy) if combo ~= 1 and go ~= 0 then return end if su == false then su = true shield1 = true Tool.Shielding.Value = true weld10 = weld1.C0 weld11 = weld1.C1 weld20 = weld2.C0 weld21 = weld2.C1

weld2.C0 = CFrame.new(1.5,0.5,0) weld2.C1 = CFrame.new(0,0.5,0)*CFrame.fromEulerAnglesXYZ(math.pi/-2, 0, 0) weld1.C0 = CFrame.new(-1.5,0.5,0)

Tool.Handle.ShieldUp:play()

guy["Humanoid"].WalkSpeed = 8

for i=1,5 do weld1.C0 = weld1.C0 * CFrame.fromEulerAnglesXYZ(math.pi/64, math.pi/-20, math.pi/64) + Vector3.new(0.05,-0.04,-0.15) weld2.C0 = weld2.C0 * CFrame.fromEulerAnglesXYZ(math.pi/-10, 0, math.pi/-128) wait() end

local hum = guy:findFirstChild("Humanoid") if hum ~= nil then oldHealth = hum.Health con1 = hum.ChildAdded:connect(function(cr) if cr.Name == "creator" then checkBlock(guy,hum,cr) end end) end

shieldLoop(guy)

su = false end end

function shieldLoop(guy)

while true do

if Tool.Parent ~= guy then shieldDown(guy) return end

if eCheck() == false then wait(0.1) shieldDown(guy) return end

if guy["Humanoid"].WalkSpeed > 8 then guy["Humanoid"].WalkSpeed = 8 end

sap((Tool.Energy.Value)/10) if Tool.Shielding.Value == false then break end

wait(0.1)

end

shieldDown(guy)

end

function shieldDown(guy) if combo ~= 1 and go ~= 0 then return end if sd == false then sd = true shield = true weld10 = weld1.C0 weld11 = weld1.C1 weld20 = weld2.C0 weld21 = weld2.C1

weld2.C0 = CFrame.new(1.5,0.5,0) weld2.C1 = CFrame.new(0,0.5,0)*CFrame.fromEulerAnglesXYZ(math.pi/-2, 0, 0) weld1.C0 = CFrame.new(-1.5,0.5,0) for i=1,5 do local rg = guy["Right Arm"]:findFirstChild("RightGrip") weld1.C0 = weld1.C0 * CFrame.fromEulerAnglesXYZ(math.pi/64, math.pi/-20, math.pi/64) + Vector3.new(0.05,-0.04,-0.15) weld2.C0 = weld2.C0 * CFrame.fromEulerAnglesXYZ(math.pi/-10, 0, math.pi/-128) end

con1:disconnect()

Tool.Shielding.Value = false

for i=1,5 do weld1.C0 = weld1.C0 * CFrame.fromEulerAnglesXYZ(math.pi/-64, math.pi/20, math.pi/-64) + Vector3.new(-0.05,0.04,0.15) weld2.C0 = weld2.C0 * CFrame.fromEulerAnglesXYZ(math.pi/10, 0, math.pi/128) wait() end

guy["Humanoid"].WalkSpeed = 17

weld2.C0 = CFrame.new(1.5,0.5,0) weld2.C1 = CFrame.new(0,0.5,0)*CFrame.fromEulerAnglesXYZ(math.pi/-2, 0, 0) weld1.C0 = CFrame.new(-1.5,0.5,0)

endSap()

Tool.Shielding.Value = false

shield1 = false sd = false end end

function correctAngle(guy,guy1) local t = guy1:findFirstChild("Torso") if t ~= nil then local torso = guy.Torso local ray1 = Ray.new(torso.Position, (t.Position - torso.Position).unit) if ray1:Distance(torso.Position+torso.CFrame.lookVector*3) <= 2.5 then return true end else end return false end

function findAttacker(guy,plyr1) local player = plyr1 if player ~= nil then local guy1 = player.Character if guy1 ~= nil then return guy1 end end return nil end

function checkBlock(guy,hum,creator) local plyr = game.Players:GetPlayerFromCharacter(guy) if plyr == nil then return end local plyr1 = creator.Value if plyr1 == currentP or plyr1 == plyr then return end if hum.Health < oldHealth then currentP = plyr1 hDif = oldHealth - hum.Health guy1 = findAttacker(guy,plyr1) if guy1 ~= nil then if correctAngle(guy,guy1) == true then block(guy,guy1,hum,hDif) end end end end

function block(guy,guy1,hum,hDif) wait() print("BLOCK") Tool.Handle.Block.Pitch = 1+(math.random(-25,25)/100) Tool.Handle.Block:play() local t = guy1:findFirstChild("Torso") if t ~= nil then local torso = guy.Torso local Push = Instance.new("BodyVelocity") Push.P = 1000 Push.maxForce = Vector3.new(500000,500000,500000)*50000 Push.velocity = (torso.Position - t.Position).unit * hDif Push.Parent = torso game:GetService("Debris"):AddItem(Push,.35) local plyr = game.Players:GetPlayerFromCharacter(guy) hum.Health = oldHealth - (hDif * ((100-Tool.Percent.Value-90)/100)) wait() oldHealth = hum.Health currentP = nil end end

function slash1(guy) weld20=weld2.C0 weld21=weld2.C1 grip = guy["Right Arm"].RightGrip.C1 sap(Tool.Energy.Value) guy["Humanoid"].WalkSpeed = 5 for i=1,4 do local rg = guy["Right Arm"]:findFirstChild("RightGrip") if rg ~= nil then weld2.C0 = weld2.C0CFrame.fromEulerAnglesXYZ(math.pi/-6, math.pi/-8, 0) weld2.C0 = weld2.C0+Vector3.new(0.05,0,0.05) guy["Right Arm"].RightGrip.C1 = guy["Right Arm"].RightGrip.C1 * CFrame.fromEulerAnglesXYZ(math.pi/5,0,0) end wait() end wait() Tool.Handle.Slash:play() local d = dmg310 damage = math.random(d, (d+20))/10 Con = Tool.Blade1.Touched:connect(function(hit) blow(hit, damage) end) Tool.Cut.Value=true for i = 1,11 do local rg = guy["Right Arm"]:findFirstChild("RightGrip") if rg ~= nil then weld1.C0 = weld1.C0CFrame.fromEulerAnglesXYZ(0, math.pi/28, 0)+Vector3.new(0.0275,0,0.015) weld2.C0 = weld2.C0CFrame.fromEulerAnglesXYZ(math.pi/9.5, 0, 0) weld2.C0 = weld2.C0+Vector3.new(-0.06,0,-0.065) end wait() end Tool.Cut.Value=false wait() damage=0 Con:disconnect() guy["Humanoid"].WalkSpeed=10 wait(0.21) endSap() weld1.C0 = CFrame.new(-1.5,0.5,0) weld2.C0 = CFrame.new(1.5,0.5,0) weld2.C1 = CFrame.new(0,0.5,0)*CFrame.fromEulerAnglesXYZ(math.pi/-2, 0, 0) local rg = guy["Right Arm"]:findFirstChild("RightGrip") if rg ~= nil then guy["Right Arm"].RightGrip.C1 = grip end end

function slash2(guy) weld20 = weld2.C0 weld21 = weld2.C1 grip = guy["Right Arm"].RightGrip.C1 sap(Tool.Energy.Value) for i=1,4 do local rg = guy["Right Arm"]:findFirstChild("RightGrip") if rg ~= nil then weld2.C0 = weld2.C0 * CFrame.fromEulerAnglesXYZ(math.pi/4, math.pi/-20, 0) weld2.C0 = weld2.C0 + Vector3.new(0,0.05,0) guy["Right Arm"].RightGrip.C1 = guy["Right Arm"].RightGrip.C1 * CFrame.fromEulerAnglesXYZ(math.pi/32,0,0) end wait() end wait() guy["Humanoid"].WalkSpeed = 5 Tool.Handle.Slash:play() local d = dmg110 damage = math.random(d, (d+15))/10 Con = Tool.Blade1.Touched:connect(function(hit) blow(hit, damage) end) Tool.Cut.Value = true for i = 1,11 do local rg = guy["Right Arm"]:findFirstChild("RightGrip") if rg ~= nil then weld1.C0 = weld1.C0CFrame.fromEulerAnglesXYZ(0, math.pi/128, 0) + Vector3.new(0,0,0.025) weld2.C0 = weld2.C0CFrame.fromEulerAnglesXYZ(math.pi/-9.25, 0, 0) guy["Right Arm"].RightGrip.C1 = guy["Right Arm"].RightGrip.C1 * CFrame.fromEulerAnglesXYZ(math.pi/35,0,0) weld2.C0 = weld2.C0+Vector3.new(0,-0.0175,-0.01) end wait() end Tool.Cut.Value = false wait() damage = 0 Con:disconnect() guy["Humanoid"].WalkSpeed = 10 wait(0.21) endSap() weld1.C0 = CFrame.new(-1.5,0.5,0) weld2.C0 = CFrame.new(1.5,0.5,0) weld2.C1 = CFrame.new(0,0.5,0)CFrame.fromEulerAnglesXYZ(math.pi/-2, 0, 0) local rg = guy["Right Arm"]:findFirstChild("RightGrip") if rg ~= nil then guy["Right Arm"].RightGrip.C1 = grip end end

function slash3(guy) weld20=weld2.C0 weld21=weld2.C1 grip = guy["Right Arm"].RightGrip.C1 sap(Tool.Energy.Value) guy["Humanoid"].WalkSpeed = 5 for i=1,3 do local rg = guy["Right Arm"]:findFirstChild("RightGrip") if rg ~= nil then weld2.C0 = weld2.C0CFrame.fromEulerAnglesXYZ(0, 0, math.pi/64) weld2.C0 = weld2.C0+Vector3.new(0,0.025,0.115) guy["Right Arm"].RightGrip.C1 = guy["Right Arm"].RightGrip.C1 * CFrame.fromEulerAnglesXYZ(math.pi/24,0,0) end wait() end wait() Tool.Handle.Slash:play() local d = dmg310 damage = math.random(d, (d+20))/10 Con = Tool.Blade1.Touched:connect(function(hit) blow(hit, damage) end) Tool.Cut.Value=true for i = 1,6 do local rg = guy["Right Arm"]:findFirstChild("RightGrip") if rg ~= nil then weld2.C0 = weld2.C0 * CFrame.fromEulerAnglesXYZ(0, math.pi/128, 0) guy["Right Arm"].RightGrip.C1 = guy["Right Arm"].RightGrip.C1 * CFrame.fromEulerAnglesXYZ(math.pi/15,0,0) weld2.C0 = weld2.C0+Vector3.new(0,0,-0.15) end wait() end Tool.Cut.Value=false wait() damage=0 Con:disconnect() guy["Humanoid"].WalkSpeed=6 wait(0.21) endSap() weld1.C0 = CFrame.new(-1.5,0.5,0) weld2.C0 = CFrame.new(1.5,0.5,0) weld2.C1 = CFrame.new(0,0.5,0)*CFrame.fromEulerAnglesXYZ(math.pi/-2, 0, 0) local rg = guy["Right Arm"]:findFirstChild("RightGrip") if rg ~= nil then guy["Right Arm"].RightGrip.C1 = grip end end

0
This is not a site to ask others to do work for you (and your time wasted is, at any rate, not compensation for someone else's). Come back if you have a specific, small question to ask. BlueTaslem 18071 — 9y

Closed as Not Constructive by BlueTaslem

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?