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: Anyway to avoid from dropping hats?

Previous Thread :: Next Thread 
badgraphix is not online. badgraphix
Joined: 26 Nov 2007
Total Posts: 22800
22 Mar 2012 05:14 PM
I'm wondering if there's a relatively easy way to do this.
Report Abuse
18cwatford is not online. 18cwatford
Joined: 08 Oct 2009
Total Posts: 5410
22 Mar 2012 05:30 PM
I think you want it so the player keeps their hats, just can't drop them. Here, your very nice about it.
Put this in the player:

function onChildRemoved(obj)
if obj:IsA("Hat") then
obj.Parent = script.Parent.Character
end
end

script.Parent.Character.ChildRemoving:connect(onChildRemoved)



I'm not completely sure that'll work though :\
Report Abuse
thek00lkid is not online. thek00lkid
Joined: 18 Jun 2011
Total Posts: 2778
22 Mar 2012 05:34 PM
That might not work, but at least when they die, they're hat gets destroyed. It also can't get picked up by players that way.
Report Abuse
18cwatford is not online. 18cwatford
Joined: 08 Oct 2009
Total Posts: 5410
22 Mar 2012 05:36 PM
if obj.Parent ~= nil

-_-
Report Abuse
thek00lkid is not online. thek00lkid
Joined: 18 Jun 2011
Total Posts: 2778
22 Mar 2012 05:38 PM
?

I'm just saying, if the hat is a descendant of a player, it'll be destroyed on death.
Report Abuse
badgraphix is not online. badgraphix
Joined: 26 Nov 2007
Total Posts: 22800
22 Mar 2012 06:05 PM
Thanks for the script 18cwatford. With a few tweaks I was able to get it working.


Instead of putting it in the player, I put it in the character (scripts only function in Workspace) and without a wait it will crash.

function onChildRemoved(obj)
if obj:IsA("Hat") then
wait(0.0001)
obj.Parent = script.Parent
end
end

script.Parent.ChildRemoved:connect(onChildRemoved)
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
22 Mar 2012 07:09 PM
@Badgraphix

Scripts function in the Workspace, Backpack, StarterGui, and all descendants of the players.

The script you would want uses the DescendantAdded.

Workspace.DescendantAdded:connect(d)
if d:IsA("Hat") then
d:Remove()
end
end)
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
22 Mar 2012 07:11 PM
If I'm understanding right, you still want them on the characters, but not able to be taken off? MrNicNac's would let them remove their hats and then the hats would be removed.
Report Abuse
ArbiterOfDeath is not online. ArbiterOfDeath
Joined: 20 Jun 2011
Total Posts: 1458
22 Mar 2012 07:12 PM
Mr.NicNack, I have a question for you, what is the diffrance between "ClassName" "className" and "IsA()"?
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
22 Mar 2012 07:13 PM
Ahem...super blasphemy...woops. Mine actually deletes the hat when the character happens to wander into the Workspace. How unfortunate.

Workspace.DescendantAdded:connect(d)
if d:IsA("Hat") and not Game.Players:GetPlayerFromCharacter(d.Parent) then
d:Remove()
end
end)
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
22 Mar 2012 07:15 PM
@ArbitratorOfDeath (spelled...wrong right wrong...who knows)

IsA() holds a few special attributes (big words shouldn't be used in explanations...)

Anyways. When you call IsA() on a string, it accepts super classes, and not just class names.

A super class might be BasePart, which incorporates Trusses, VehicleSeats, Parts, and anything physical really.

if part:IsA("BasePart") then

if the part is a truss, or anything physical (besides particle effects) then it will return true and continue with the statement.

if part.className = "BasePart" then

that will never work.
Report Abuse
Maelstronomer is not online. Maelstronomer
Joined: 07 Jun 2008
Total Posts: 7649
22 Mar 2012 07:16 PM
This is sweet. Thanks badgraphix I got it to work with a custom script to put it in the character. I'll put it in my pending Models To Make Free list.
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