Hopeless2
|
  |
| Joined: 19 Oct 2011 |
| Total Posts: 246 |
|
|
| 02 Mar 2013 08:39 AM |
Hello.
This isn't working:
p = if hit.Parent:FindFirstChild("Trolly")
function onTouched (hit)
p then p:Deselect() wait(0.3) p:Destroy() end end
script.Parent.Touched:connect(onTouched)
Can you do :Deselect(), or is it something else? - Thanks.
|
|
|
| Report Abuse |
|
|
|
| 02 Mar 2013 08:43 AM |
I don't thin deselect exsist so i'll leave that to someone else.
function onTouched (hit) if hit.Parent == hit.Parent:findFirstChild("Trolly") then --code
end end
" p = if hit.Parent:FindFirstChild("Trolly")"
That line is outside of the function so hit is not defined yet.
|
|
|
| Report Abuse |
|
|
|
| 02 Mar 2013 08:44 AM |
p = hit.Parent:FindFirstChild("Trolly")
function onTouched (hit)
if p then p:Deselect() wait(0.3) p:Destroy() end end
script.Parent.Touched:connect(onTouched)
|
|
|
| Report Abuse |
|
|
|
| 02 Mar 2013 08:44 AM |
| also, change p then to if p then. But dont forget the end! |
|
|
| Report Abuse |
|
|
|
| 02 Mar 2013 08:45 AM |
@pokemon771:
You are right :/
Use Humanoid.UnequipTools() |
|
|
| Report Abuse |
|
|
|
| 02 Mar 2013 08:47 AM |
Also, the line p = if hit.Parent:FindFirstChild("Trolly") has to be in the function because hit is not defined outside of the function.
|
|
|
| Report Abuse |
|
|
|
| 02 Mar 2013 08:47 AM |
OOps I mean
if hit.Parent == hit.Parent:findFirstChild("Trolly") then
not p = if hit.Parent:FindFirstChild("Trolly") |
|
|
| Report Abuse |
|
|
|
| 02 Mar 2013 08:50 AM |
tell us if it works please.
|
|
|
| Report Abuse |
|
|
Hopeless2
|
  |
| Joined: 19 Oct 2011 |
| Total Posts: 246 |
|
|
| 02 Mar 2013 08:51 AM |
I'm not all that good a Scripter. I'm more of a newbie.
What I got was...
p = hit.Parent:FindFirstChild("Trolly")
function onTouched (hit)
if hit.Parent == hit.Parent:findFirstChild("Trolly") then hit.Humanoid.UnequipTools() wait(0.3) p:Destroy() end end
script.Parent.Touched:connect(onTouched)
And no, it didn't work. What did I do wrong? |
|
|
| Report Abuse |
|
|
|
| 02 Mar 2013 08:59 AM |
pokemon771 has messed up your if statement, unless Trolly is a part in yuor character (I assume its a tool)
function onTouched (hit)
if hit.Parent and hit.Name == "Handle" and hit.Parent.Parent:findFirstChild("Trolly") then --Check for its name to be handle and that Trolly exists local p = hit.Parent.Trolly --Get trolly hit.Parent.Humanoid:UnequipTools() --Deselect your everything wait(0.3) --Dont need this, really p:Destroy() --It would be best to just destroy it, really. end end
script.Parent.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
|
| 02 Mar 2013 09:07 AM |
OHHH thats right I forgot the name sorry about that. I don't code in rbx.lua anymore.
|
|
|
| Report Abuse |
|
|
Hopeless2
|
  |
| Joined: 19 Oct 2011 |
| Total Posts: 246 |
|
|
| 02 Mar 2013 09:08 AM |
Yes, Trolly is a tool.
That doesn't seem to be working either. The problem initially was when if I just removed the tool when you touched the part, because it has a hand weld, it would remove the tool, but keep the hand weld in the same position. I wanted to hand weld to return to normal, (none), so I thought if the tool was deselected before it was removed, it would fix that.
|
|
|
| Report Abuse |
|
|
|
| 02 Mar 2013 09:08 AM |
Sorry, I forgot:
Add a second .Parent before the .Humanoid |
|
|
| Report Abuse |
|
|
|
| 02 Mar 2013 09:11 AM |
| Maybe post the output too? |
|
|
| Report Abuse |
|
|
Hopeless2
|
  |
| Joined: 19 Oct 2011 |
| Total Posts: 246 |
|
|
| 02 Mar 2013 09:11 AM |
Added that in, still not working.
Is it possible to have a script just in the Workspace or something which checks when somebody is not holding a tool, and resets their arm weld to nothing? |
|
|
| Report Abuse |
|
|
Hopeless2
|
  |
| Joined: 19 Oct 2011 |
| Total Posts: 246 |
|
|
| 02 Mar 2013 09:12 AM |
15:10:26.925 - Trolly is not a valid member of Tool 15:10:26.926 - Script "Workspace.Part.Script", Line 4 15:10:26.926 - stack end 15:10:26.926 - Disconnected event because of exception |
|
|
| Report Abuse |
|
|
|
| 02 Mar 2013 09:12 AM |
if hit.Parent and hit.Name == "Handle" and hit.Parent.Parent:findFirstChild("Trolly") then --Check for its name to be handle and that Trolly exists local p = hit.Parent.Parent.Trolly --Get trolly hit.Parent.Parent.Humanoid:UnequipTools() --Deselect your everything wait(0.3) --Dont need this, really p:Destroy() --It would be best to just destroy it, really. end end
script.Parent.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
|
| 02 Mar 2013 09:12 AM |
script.Parent.Deselected:connect(function() print("Deselected") end)
|
|
|
| Report Abuse |
|
|
Hopeless2
|
  |
| Joined: 19 Oct 2011 |
| Total Posts: 246 |
|
|
| 02 Mar 2013 09:23 AM |
@ Notunknown99 - Still didn't work.
@Pokemon771 - Didn't print in the Output. |
|
|
| Report Abuse |
|
|
|
| 02 Mar 2013 09:32 AM |
did you put it in the tool and deselect it?
|
|
|
| Report Abuse |
|
|
|
| 02 Mar 2013 09:34 AM |
>_>
Something is wrong with me today, didnt copy the function...
function onTouched(hit) if hit.Parent and hit.Name == "Handle" and hit.Parent.Parent:findFirstChild("Trolly") then --Check for its name to be handle and that Trolly exists local p = hit.Parent.Parent.Trolly --Get trolly hit.Parent.Parent.Humanoid:UnequipTools() --Deselect your everything wait(0.3) --Dont need this, really p:Destroy() --It would be best to just destroy it, really. end end
script.Parent.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
Hopeless2
|
  |
| Joined: 19 Oct 2011 |
| Total Posts: 246 |
|
|
| 02 Mar 2013 09:45 AM |
YES! It's finally working!
Well, it took a whole day for me, but it was worth it. Thank you everyone. =) |
|
|
| Report Abuse |
|
|