generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Scripting help.

Previous Thread :: Next Thread 
wally5026 is not online. wally5026
Joined: 28 Dec 2010
Total Posts: 503
14 Aug 2013 07:09 PM
This Script works for 1 sword hit and then it breaks and the sword no longer does damage.


r = game:service("RunService")
ching = false
sword = script.Parent.Handle
Tool = script.Parent
function blow(hit)
if ching == true then return end
local humanoid = hit.Parent:findFirstChild("Humanoid")
local vCharacter = Tool.Parent
local vPlayer = game.Players:playerFromCharacter(vCharacter)
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/5),script.Parent.MaxDmg.Value+math.floor(vPlayer.attributes.Strength.Value/5))+math.floor(vPlayer.leaderstats.Lvl.Value/5)
humanoid:TakeDamage(damage)
local part = Instance.new("ScreenGui")
local part2 = Instance.new("TextLabel")
c1 = script.FadeClean:Clone()
c2 = script.TextRiser:Clone()
part2.FontSize = "Size24"
part2.Font = "ArialBold"
part2.Size = UDim2.new(0,50,0,50)
part2.Position = UDim2.new(0.5,0,0.25,0)
part2.BackgroundTransparency = 1
part2.Parent = part
c1.Parent = part2
c1.Disabled = false
c2.Parent = part2
c2.Disabled = false
part.Parent = vPlayer.PlayerGui
if (damage == 0) then
part2.TextColor3 = Color3.new(0/255,102/255,255/255)
else
part2.TextColor3 = Color3.new(255/255,255/255,255/255)
end
part2.Text = ""..damage..""
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 anim = Instance.new("StringValue")
anim.Name = "toolanim"
anim.Value = "Slash"
anim.Parent = Tool
end

function lunge()

local anim = Instance.new("StringValue")
anim.Name = "toolanim"
anim.Value = "Lunge"
anim.Parent = Tool


force = Instance.new("BodyVelocity")
force.velocity = Vector3.new(0,10,0) --Tool.Parent.Torso.CFrame.lookVector * 80
force.Parent = Tool.Parent.Torso
wait(.25)
swordOut()
wait(.25)
force.Parent = nil
wait(.5)
swordUp()

damage = slash_damage
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

function swordAcross()
-- parry
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
print("Humanoid not found")
return
end

attack()

wait(1)

Tool.Enabled = true
end


function onEquipped()

end


script.Parent.Activated:connect(onActivated)
script.Parent.Equipped:connect(onEquipped)


connection = sword.Touched:connect(blow)
Report Abuse
ShagFace is not online. ShagFace
Joined: 22 Aug 2011
Total Posts: 3474
14 Aug 2013 07:28 PM
The second "ching" in the script, needs to be false.
Because the Humanoid won't ~= nil, because of its health

I think that may be what causes your script to be inoperable
If not, then I think the script may just be too long and complex, for an individual object to carry, therefore making it crash.
Report Abuse
skillcapeman is not online. skillcapeman
Joined: 20 Feb 2011
Total Posts: 2885
14 Aug 2013 07:30 PM
Here,

r = game:service("RunService")
ching = false
sword = script.Parent.Handle
Tool = script.Parent
function blow(hit)
if ching == true then return end
local humanoid = hit.Parent:findFirstChild("Humanoid")
local vCharacter = Tool.Parent
local vPlayer = game.Players:playerFromCharacter(vCharacter)
if humanoid~=nil then
ching = false
print("SWORD HIT")
tagHumanoid(humanoid, vPlayer)
local damage = math.random(script.Parent.MinDmg.Value+math.floor(vPlayer.attributes.Strength.Value/5),script.Parent.MaxDmg.Value+math.floor(vPlayer.attributes.Strength.Value/5))+math.floor(vPlayer.leaderstats.Lvl.Value/5)
humanoid:TakeDamage(damage)
local part = Instance.new("ScreenGui")
local part2 = Instance.new("TextLabel")
c1 = script.FadeClean:Clone()
c2 = script.TextRiser:Clone()
part2.FontSize = "Size24"
part2.Font = "ArialBold"
part2.Size = UDim2.new(0,50,0,50)
part2.Position = UDim2.new(0.5,0,0.25,0)
part2.BackgroundTransparency = 1
part2.Parent = part
c1.Parent = part2
c1.Disabled = false
c2.Parent = part2
c2.Disabled = false
part.Parent = vPlayer.PlayerGui
if (damage == 0) then
part2.TextColor3 = Color3.new(0/255,102/255,255/255)
else
part2.TextColor3 = Color3.new(255/255,255/255,255/255)
end
part2.Text = ""..damage..""
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 anim = Instance.new("StringValue")
anim.Name = "toolanim"
anim.Value = "Slash"
anim.Parent = Tool
end

function lunge()

local anim = Instance.new("StringValue")
anim.Name = "toolanim"
anim.Value = "Lunge"
anim.Parent = Tool


force = Instance.new("BodyVelocity")
force.velocity = Vector3.new(0,10,0) --Tool.Parent.Torso.CFrame.lookVector * 80
force.Parent = Tool.Parent.Torso
wait(.25)
swordOut()
wait(.25)
force.Parent = nil
wait(.5)
swordUp()

damage = slash_damage
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

function swordAcross()
-- parry
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
print("Humanoid not found")
return
end

attack()

wait(1)

Tool.Enabled = true
end


function onEquipped()

end


script.Parent.Activated:connect(onActivated)
script.Parent.Equipped:connect(onEquipped)


connection = sword.Touched:connect(blow)
Report Abuse
MHebes is not online. MHebes
Joined: 04 Jan 2013
Total Posts: 2278
14 Aug 2013 07:30 PM
"I think the script may just be too long and complex, for an individual object to carry, therefore making it crash."
That doesn't really happen.

~ Oh, I'm sorry, did I break your concentration? ~
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image