|
| 22 Mar 2012 05:14 PM |
| I'm wondering if there's a relatively easy way to do this. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
| |
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|