Bulvyte
|
  |
| Joined: 21 May 2014 |
| Total Posts: 716 |
|
|
| 06 Aug 2016 04:26 PM |
Im having a problem with my sword it does damage when u touch other player without activating the sword, and i really want to do damage when u activated it and when u stand still u can do damage... How can u fix that ?
|
|
|
| Report Abuse |
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 06 Aug 2016 04:28 PM |
| That's actually a variable you can change inside of the sword script itself, assuming you're using the classic ROBLOX sword. |
|
|
| Report Abuse |
|
Bulvyte
|
  |
| Joined: 21 May 2014 |
| Total Posts: 716 |
|
|
| 06 Aug 2016 04:51 PM |
Heres the script. I used debounces none worked ;-;
repeat wait() until game.Players.LocalPlayer.Character repeat wait() until game.Players.LocalPlayer.Character:IsDescendantOf(game.Workspace) wait(1 / 20)
local player = game.Players.LocalPlayer local char = game.Players.LocalPlayer.Character local Humanoid = char.Humanoid local unsheathA = script.Parent:WaitForChild('unsheathA') local sheathA = script.Parent:WaitForChild('sheathA') local spinA = script.Parent:WaitForChild('spinA') local swingA = script.Parent:WaitForChild('swingA') local unsheath = script.Parent:WaitForChild('unsheath') local sheath = script.Parent:WaitForChild('sheath') local spin = script.Parent:WaitForChild('spin') local swing = script.Parent:WaitForChild('swing')
local r = game:GetService("RunService") local ching = false local sword = script.Parent.Handle local Tool = script.Parent local canNotHit = true -- i used these debounces none helped
function blow(hit) if ching and canNotHit then return end canNotHit = true local humanoid = hit.Parent:FindFirstChild("Human") local vCharacter = char local vPlayer = game.Players:GetPlayerFromCharacter(vCharacter) --Did the weapon hit player? Check if PvP is enabled. if humanoid == nil then local hitPlayer = game.Players:GetPlayerFromCharacter(hit.Parent) if hitPlayer ~= nil then if game.Workspace.GAME_PROPERTIES.HasPvP.Value == true and hitPlayer.Stats.InPvP.Value == true and hitPlayer.leaderstats.Lvl.Value >= game.Workspace.GAME_PROPERTIES.PvPLevelMinimum.Value then --Is the player in PvP areas? if hitPlayer.leaderstats.Lvl.Value >= vPlayer.leaderstats.Lvl.Value - game.Workspace.GAME_PROPERTIES.PvPLevelRange.Value and hitPlayer.leaderstats.Lvl.Value <= vPlayer.leaderstats.Lvl.Value + game.Workspace.GAME_PROPERTIES.PvPLevelRange.Value then humanoid = hit.Parent:FindFirstChild("Humanoid") end end end end --If humanoid is found, damage. if humanoid ~= nil then ching = true print("SWORD HIT") tagHumanoid(humanoid, vPlayer) local damage = math.random(script.Parent.MinDmg.Value+math.floor(vPlayer.attributes.Strength.Value/2),script.Parent.MaxDmg.Value+math.floor(vPlayer.attributes.Strength.Value/2))+math.floor(vPlayer.leaderstats.Lvl.Value/5) local hitroll = math.random(1, 100) local critroll = math.random(1, 100) if game.Players:GetPlayerFromCharacter(hit.Parent) ~= nil then if game.Workspace.GAME_PROPERTIES.BaseHitChance.Value == 1 then damage = math.floor(damage * (1 - (game.Players:GetPlayerFromCharacter(hit.Parent).Stats.Defense.Value / 100))) elseif game.Workspace.GAME_PROPERTIES.BaseHitChance.Value == 2 then damage = math.floor(damage - game.Players:GetPlayerFromCharacter(hit.Parent).Stats.Defense.Value) end if damage < 1 then damage = 1 end --minimum dmg 1 end --Hit and critical modifier. if hitroll > game.Workspace.GAME_PROPERTIES.BaseHitChance.Value + (vPlayer.attributes.Dexterity.Value * (game.Workspace.GAME_PROPERTIES.HitChanceDexMagnitude.Value/100)) then damage = 0 end if critroll <= game.Workspace.GAME_PROPERTIES.BaseCritChance.Value + (vPlayer.attributes.Dexterity.Value * (game.Workspace.GAME_PROPERTIES.CritChanceDexMagnitude.Value/100)) then damage = damage * (script.Parent.CritMagnitude.Value / 100) -- Percentage. end --Enemy health bar GUI if vPlayer.PlayerGui:FindFirstChild("EnemyInfo") ~= nil and humanoid.Health > 0 then vPlayer.PlayerGui:FindFirstChild("EnemyInfo").EnemyBar.TickUntilRemove.Value = 200 vPlayer.PlayerGui:FindFirstChild("EnemyInfo").EnemyBar.Tag.Value = humanoid.Parent end --Damages humanoid humanoid:TakeDamage(damage) --Floating damage text local part = Instance.new("BillboardGui") part.Size = UDim2.new(0,50,0,100) part.StudsOffset = Vector3.new(0,2,0) local part2 = Instance.new("TextLabel") dt = game.ReplicatedStorage.DynamicText:Clone() part2.Font = "SourceSansBold" part2.FontSize = "Size24" part2.TextStrokeTransparency = 0 part2.Size = UDim2.new(1,0,1,0) part2.Position = UDim2.new(0,0,0,0) part2.BackgroundTransparency = 1 part2.Parent = part dt.Parent = part2 dt.Disabled = false part.Parent = humanoid.Parent.Head part.Adornee = part.Parent --Shows text if (damage == 0) then part2.TextColor3 = Color3.new(0,0.5,1) part2.Text = "Miss!" else part2.TextColor3 = Color3.new(1,1,1) if critroll <= game.Workspace.GAME_PROPERTIES.BaseCritChance.Value + (vPlayer.attributes.Dexterity.Value * (Game.Workspace.GAME_PROPERTIES.CritChanceDexMagnitude.Value/100)) then part2.TextColor3 = Color3.new(1,1,0) part2.FontSize = "Size36" part2.Text = ""..damage.."!" else part2.Text = ""..damage.."" end end wait(1) ching = false wait(.1) untagHumanoid(humanoid) end end
function tagHumanoid(humanoid, player) local creator_tag = Instance.new("ObjectValue") creator_tag.Value = player creator_tag.Name = "creator" creator_tag.Parent = humanoid end
function untagHumanoid(humanoid) if humanoid ~= nil then local tag = humanoid:findFirstChild("creator") if tag ~= nil then tag.Parent = nil end end end
function attack() local swingnspin = math.random(1, 2) if swingnspin == 1 then local swingA = Humanoid:LoadAnimation(swingA) swing:Play() swingA:Play() spin.Pitch = (math.random(125, 150) * 0.01) spin:Play() else if swingnspin == 2 then local spinA = Humanoid:LoadAnimation(spinA) spinA:Play() spin:Play() end end end
function swordUp() Tool.GripForward = Vector3.new(-1,0,0) Tool.GripRight = Vector3.new(0,1,0) Tool.GripUp = Vector3.new(0,0,1) end
function swordOut() Tool.GripForward = Vector3.new(0,0,1) Tool.GripRight = Vector3.new(0,-1,0) Tool.GripUp = Vector3.new(-1,0,0) end
Tool.Enabled = true
function onActivated()
if not Tool.Enabled then return end Tool.Enabled = false local character = Tool.Parent; local humanoid = character.Humanoid if humanoid == nil then return end attack() canNotHit = false wait(1) canNotHit = true Tool.Enabled = true end
function onDeactivated () canNotHit = true end
function onEquipped() local animTrack = Humanoid:LoadAnimation(unsheathA) animTrack:Play() wait(0.4) unsheath:Play()
end
function onUnequipped()
local animTracks = Humanoid:LoadAnimation(sheathA) animTracks:Play() wait(0.25) sheath:Play() wait(0.626) sheath:Stop() spin:Stop() swing:Stop() unsheath:Stop() end
script.Parent.Activated:connect(onActivated) -- enable hits script.Parent.Deactivated:connect(onDeactivated) -- disable hits
script.Parent.Equipped:connect(onEquipped) script.Parent.Unequipped:connect(onUnequipped)
connection = sword.Touched:connect(blow)
|
|
|
| Report Abuse |
|
Bulvyte
|
  |
| Joined: 21 May 2014 |
| Total Posts: 716 |
|
| |