Warzynski
|
  |
| Joined: 21 Nov 2010 |
| Total Posts: 7721 |
|
|
| 10 Aug 2014 12:51 AM |
Alright, so I have an unanchored bricks that are welded together that like to move around. Specically, a giant chain.
I want to have one script get all the parts in a model that are labeled "Kill" to kill any player that touches the brick.
I'm having trouble getting all the parts.
I've been moving stuff around in attempts to fix it.
prntscr /4bc0pa
--function onTouched(hit) for i,v in ipairs()(script.Parent:GetChildren()) do wait() if hit.Parent.Name == v.Name then function onTouched(hit) if hit.Parent:findFirstChild("Humanoid") ~= nil then if hit.Parent ~= nil then player.Humanoid.Health = 0 end end end end end
-- script.Parent.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
Warzynski
|
  |
| Joined: 21 Nov 2010 |
| Total Posts: 7721 |
|
| |
|
Unclear
|
  |
| Joined: 27 Aug 2011 |
| Total Posts: 17060 |
|
|
| 10 Aug 2014 12:54 AM |
Have you ever considered hooking up the Touched event onto the parts of a Character and checking for parts named "Kill" that touch them, rather than hooking up events to the "Kill" parts and verifying if the character is actually a player's character, then checking for humanoid, then doing the damage?
It's a lot less convoluted if you do it my way.
~~ tu tu tu tu tu tu ru ♪♪ |
|
|
| Report Abuse |
|
|
Unclear
|
  |
| Joined: 27 Aug 2011 |
| Total Posts: 17060 |
|
|
| 10 Aug 2014 01:01 AM |
I wrote up a server-side example dealing 20 damage with a 1 second debounce...
local Create = LoadLibrary("RbxUtility").Create
local function characterAdded(character) local player = game.Players:GetPlayerFromCharacter(character)
if player ~= nil then local humanoid = character:WaitForChild("Humanoid")
local function hookUpTouchDamage(object) local tagFound = humanoid:FindFirstChild("damageTag") if object:IsA("BasePart") and object.Name == "Kill" and tagFound == nil then game.Debris:AddItem(Create("BoolValue")({Parent = humanoid}), 1) humanoid.Health = humanoid.Health - 20 > 0 and humanoid.Health - 20 or 0 end end
character.ChildAdded:connect(function(object) if object:IsA("BasePart") then object.Touched:connect(hookUpTouchDamage) end end)
for _, object in pairs(character:GetChildren()) do if object:IsA("BasePart") then object.Touched:connect(hookUpTouchDamage) end end
end end
workspace.ChildAdded:connect(characterAdded) |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2014 01:02 AM |
| damn unclear i dont know what you just said but it turned me on |
|
|
| Report Abuse |
|
|
Warzynski
|
  |
| Joined: 21 Nov 2010 |
| Total Posts: 7721 |
|
|
| 10 Aug 2014 01:03 AM |
Examples please?
I sort of understand what you're saying but at the same time I probably don't.
So you're saying instead of checking for parts that are named "Kill" first and then checking if the character is a character and doing the damage,
check for the parts of the character that are touching the "Kill" parts? |
|
|
| Report Abuse |
|
|
Warzynski
|
  |
| Joined: 21 Nov 2010 |
| Total Posts: 7721 |
|
|
| 10 Aug 2014 01:04 AM |
| o you already posted example e.e |
|
|
| Report Abuse |
|
|
thea96
|
  |
| Joined: 09 Feb 2011 |
| Total Posts: 37634 |
|
|
| 10 Aug 2014 01:04 AM |
quick question
do UnionOperations now count as baseparts? |
|
|
| Report Abuse |
|
|
| |
|
Unclear
|
  |
| Joined: 27 Aug 2011 |
| Total Posts: 17060 |
|
|
| 10 Aug 2014 01:06 AM |
Just noticed that I messed up the debounce because I forgot to assign a name to the tag. Replace the relevant line with
game.Debris:AddItem(Create("BoolValue")({Parent = humanoid, Name = "damageTag"}), 1)
~~ tu tu tu tu tu tu ru ♪♪ |
|
|
| Report Abuse |
|
|
Unclear
|
  |
| Joined: 27 Aug 2011 |
| Total Posts: 17060 |
|
|
| 10 Aug 2014 01:06 AM |
@thea96
Yes, a UnionOperation's superclass is BasePart.
~~ tu tu tu tu tu tu ru ♪♪ |
|
|
| Report Abuse |
|
|
Warzynski
|
  |
| Joined: 21 Nov 2010 |
| Total Posts: 7721 |
|
|
| 10 Aug 2014 01:08 AM |
see i'm trying to learn this stuff but i'm so far behind its not even funny
currently just working off other people's examples/help and trying to make them better/refine them/fix them
how long have you guys been doing this for
|
|
|
| Report Abuse |
|
|
Unclear
|
  |
| Joined: 27 Aug 2011 |
| Total Posts: 17060 |
|
|
| 10 Aug 2014 01:09 AM |
I would say that I became a "competent" scripter six months ago when I decided to relearn Lua.
You know I wasn't that good before then because I was one of the developers for 7G, and even then I was just an apprentice.
~~ tu tu tu tu tu tu ru ♪♪ |
|
|
| Report Abuse |
|
|
Warzynski
|
  |
| Joined: 21 Nov 2010 |
| Total Posts: 7721 |
|
|
| 10 Aug 2014 01:11 AM |
what exactly did you specifically do to become a "competent scripter"
you and thea manage to figure it all out in like half a year |
|
|
| Report Abuse |
|
|
Warzynski
|
  |
| Joined: 21 Nov 2010 |
| Total Posts: 7721 |
|
|
| 10 Aug 2014 01:11 AM |
like did you write down Lua terms/functions on flash cards and memorize them
then test each function out and try and make an approach for it? |
|
|
| Report Abuse |
|
|
Unclear
|
  |
| Joined: 27 Aug 2011 |
| Total Posts: 17060 |
|
|
| 10 Aug 2014 01:12 AM |
The only thing you need to do is practice. Studying is a waste of time.
~~ tu tu tu tu tu tu ru ♪♪ |
|
|
| Report Abuse |
|
|
Spacetoad
|
  |
| Joined: 11 Nov 2011 |
| Total Posts: 4539 |
|
|
| 10 Aug 2014 01:13 AM |
unclear i will hurt your mind
script(off)delete end end |
|
|
| Report Abuse |
|
|
thea96
|
  |
| Joined: 09 Feb 2011 |
| Total Posts: 37634 |
|
|
| 10 Aug 2014 01:14 AM |
just read free models and read up on the wiki when you need to
start making your own simple scripts like bricks that kill when touched or team changing bricks |
|
|
| Report Abuse |
|
|
Unclear
|
  |
| Joined: 27 Aug 2011 |
| Total Posts: 17060 |
|
|
| 10 Aug 2014 01:15 AM |
Don't even bother reading other people's code. I can't even read code other people write; I can only read my own code.
~~ tu tu tu tu tu tu ru ♪♪ |
|
|
| Report Abuse |
|
|
Warzynski
|
  |
| Joined: 21 Nov 2010 |
| Total Posts: 7721 |
|
|
| 10 Aug 2014 01:17 AM |
Thanks for the help.
So best ways to practice?
Like how small did you start, or what was the first thing you made when you tried practicing? |
|
|
| Report Abuse |
|
|
Unclear
|
  |
| Joined: 27 Aug 2011 |
| Total Posts: 17060 |
|
|
| 10 Aug 2014 01:19 AM |
I learned how to script to take on the 7G project which ColourTheory asked me to do.
The third revision of 7G was the first thing I ever scripted.
Basically I don't waste my time on small projects. I only do big ones, and I do them alone without help from anyone else.
~~ tu tu tu tu tu tu ru ♪♪ |
|
|
| Report Abuse |
|
|