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: Help explaining?

Previous Thread :: Next Thread 
jmr11b is not online. jmr11b
Joined: 19 Aug 2010
Total Posts: 806
20 Aug 2012 07:17 AM
I am really sorry this is a Free Model. I am trying to understand it to make my own.
Can someone explain how this script finds the "creator" for that on line 4.
Thanks!

local Humanoid = script.Parent.Humanoid -- Change Enemy to the name of your Monsters Humanoid
function PwntX_X()
local tag = Humanoid:findFirstChild("creator")
if tag ~= nil then
if tag.Value ~= nil then
local Leaderstats = tag.Value:findFirstChild("leaderstats")
if Leaderstats ~= nil then
Leaderstats.Gold.Value = Leaderstats.Gold.Value + 2 --How Much Money Given
wait(0.1)
script:remove()
end
end
end
end
Humanoid.Died:connect(PwntX_X)
Report Abuse
jmr11b is not online. jmr11b
Joined: 19 Aug 2010
Total Posts: 806
20 Aug 2012 07:21 AM
bump
Report Abuse
juriaan is not online. juriaan
Joined: 25 Nov 2008
Total Posts: 939
20 Aug 2012 07:24 AM
A tool has a function that simple said puts a Value inside the Monster with the Attackers Player

So let's say I'm the Monster and you are the attacker.

You attack me with you weapon.
I get a Value inside my Humanoid called Creator with your Player inside it.

After a few hits I get killed.
I drop down and you get your points during to the fact that we have your name inside the Creator.

So now we can do this

function Pwn()
Tag = script.Parent.Humanoid:findfirstChild("creator")
if tag ~= nil and tag.Value ~= nil then -- The tag exist and the attacker exist
if tag:findFirstChild("leaderstats") then
-- Your code here
end
end
end


script.Parent.Humanoid.Died:connect(Pwn)
Report Abuse
jmr11b is not online. jmr11b
Joined: 19 Aug 2010
Total Posts: 806
20 Aug 2012 07:28 AM
How does it know what creator is though?
Sorry if my question dosn't make sense... I don't understand that.
Report Abuse
juriaan is not online. juriaan
Joined: 25 Nov 2008
Total Posts: 939
20 Aug 2012 07:33 AM
A weapon puts a Value (IntValue) inside the Player with there Player object.

That is the Creator value. The creator value is for the record when a Humanoid has been killed and to reward him for that.

That way a Leaderboard knows oh "That Enemy has been killed by Jaap"

Report Abuse
jmr11b is not online. jmr11b
Joined: 19 Aug 2010
Total Posts: 806
20 Aug 2012 07:34 AM
Whoa, I'm sorry, I somewhat understand better after this test. So weapons insert creator into it? What if a weapon inserts: 'Creator' into it then wouldn't the whole script fall apart? Or is creator the only thing that happens?
Report Abuse
jmr11b is not online. jmr11b
Joined: 19 Aug 2010
Total Posts: 806
20 Aug 2012 07:40 AM
THere is also another script here I want to understand. Here it is:

local larm = script.Parent:FindFirstChild("Left Arm")
local rarm = script.Parent:FindFirstChild("Right Arm")

function findNearestTorso(pos)
local list = game.Workspace:children()
local torso = nil
local dist = 15
local temp = nil
local human = nil
local temp2 = nil
for x = 1, #list do
temp2 = list[x]
if (temp2.className == "Model") and (temp2 ~= script.Parent) then
temp = temp2:findFirstChild("Torso")
human = temp2:findFirstChild("Humanoid")
if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
if (temp.Position - pos).magnitude < dist then
torso = temp
dist = (temp.Position - pos).magnitude
end
end
end
end
return torso
end

while true do
wait(0.1)
local target = findNearestTorso(script.Parent.Torso.Position)
if target ~= nil then
script.Parent.Humanoid:MoveTo(target.Position, target)
end
end

My only real question is for the while true do on the bottom, why dosn't it move straight to the target.Position? Because wouldn't it do that???
Once again sorry if I don't make sense.
Report Abuse
juriaan is not online. juriaan
Joined: 25 Nov 2008
Total Posts: 939
20 Aug 2012 07:43 AM
This is a Standard sword script.


r = game:service("RunService")


local damage = 5


local slash_damage = 10
local lunge_damage = 30

sword = script.Parent.Handle
Tool = script.Parent


local SlashSound = Instance.new("Sound")
SlashSound.SoundId = "rbxasset://sounds\\swordslash.wav"
SlashSound.Parent = sword
SlashSound.Volume = .7

local LungeSound = Instance.new("Sound")
LungeSound.SoundId = "rbxasset://sounds\\swordlunge.wav"
LungeSound.Parent = sword
LungeSound.Volume = .6

local UnsheathSound = Instance.new("Sound")
UnsheathSound.SoundId = "rbxasset://sounds\\unsheath.wav"
UnsheathSound.Parent = sword
UnsheathSound.Volume = 1


function blow(hit)
if (hit.Parent == nil) then return end -- happens when bullet hits sword

local humanoid = hit.Parent:findFirstChild("Humanoid")
local vCharacter = Tool.Parent
local vPlayer = game.Players:playerFromCharacter(vCharacter)
local hum = vCharacter:findFirstChild("Humanoid") -- non-nil if tool held by a character
if humanoid~=nil and humanoid ~= hum and hum ~= nil then
-- final check, make sure sword is in-hand

local right_arm = vCharacter:FindFirstChild("Right Arm")
if (right_arm ~= nil) then
local joint = right_arm:FindFirstChild("RightGrip")
if (joint ~= nil and (joint.Part0 == sword or joint.Part1 == sword)) then
tagHumanoid(humanoid, vPlayer)
humanoid:TakeDamage(damage)
wait(1)
untagHumanoid(humanoid)
end
end


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()
damage = slash_damage
SlashSound:play()
local anim = Instance.new("StringValue")
anim.Name = "toolanim"
anim.Value = "Slash"
anim.Parent = Tool
end

function lunge()
damage = lunge_damage

LungeSound:play()

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
local last_attack = 0
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

t = r.Stepped:wait()

if (t - last_attack < .2) then
lunge()
else
attack()
end

last_attack = t

--wait(.5)

Tool.Enabled = true
end


function onEquipped()
UnsheathSound:play()
end


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


connection = sword.Touched:connect(blow)



Like you see this function is quite simple (It tags the Creator)

function tagHumanoid(humanoid, player)
local creator_tag = Instance.new("ObjectValue")
creator_tag.Value = player
creator_tag.Name = "creator"
creator_tag.Parent = humanoid
end

This part of the Script creates the Creator IntValue inside the Humanoid !


Report Abuse
jmr11b is not online. jmr11b
Joined: 19 Aug 2010
Total Posts: 806
20 Aug 2012 07:47 AM
Ok, I understand better. Now how about that follow script, sorry bout all my questions :(
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