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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Deselect - Not Working

Previous Thread :: Next Thread 
Hopeless2 is not online. 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
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
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
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
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
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
02 Mar 2013 08:44 AM
also, change p then to if p then. But dont forget the end!
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
02 Mar 2013 08:45 AM
@pokemon771:

You are right :/

Use Humanoid.UnequipTools()
Report Abuse
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
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
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
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
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
02 Mar 2013 08:50 AM
tell us if it works please.
Report Abuse
Hopeless2 is not online. 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
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
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
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
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 is not online. 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
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
02 Mar 2013 09:08 AM
Sorry, I forgot:

Add a second .Parent before the .Humanoid
Report Abuse
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
02 Mar 2013 09:11 AM
Maybe post the output too?
Report Abuse
Hopeless2 is not online. 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 is not online. 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
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
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
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
02 Mar 2013 09:12 AM
script.Parent.Deselected:connect(function()
print("Deselected")
end)



Report Abuse
Hopeless2 is not online. 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
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
02 Mar 2013 09:32 AM
did you put it in the tool and deselect it?
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
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 is not online. 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
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