Tagap1234
|
  |
| Joined: 14 Jul 2012 |
| Total Posts: 182 |
|
|
| 10 Jan 2017 03:12 PM |
Hello, guys.
Here's an example of a working hat giver script:
local up = Vector3.new() local forward = Vector3.new() local pos = Vector3.new() local right = Vector3.new() debounce = true function onTouched(hit) if (hit.Parent:findFirstChild("Humanoid") ~= nil and debounce == true) then debounce = false h = Instance.new("Hat") p = Instance.new("Part") h.Name = script.Parent.Name p.Parent = h p.Position = hit.Parent:findFirstChild("Head").Position p.Name = "Handle" p.formFactor = 0 p.Size = Vector3.new(1,2,2) p.BottomSurface = 0 p.TopSurface = 0 p.Locked = true script.Parent.Mesh:clone().Parent = p h.Parent = hit.Parent h.AttachmentForward = Vector3.new(0, 0, -1) h.AttachmentPos = Vector3.new(0, 1.5, -0.05) h.AttachmentRight = Vector3.new(1, 0, 0) h.AttachmentUp = Vector3.new(0, 1, 0) wait(5) debounce = true end end script.Parent.Touched:connect(onTouched)
If you try that script, whenever you touch that part that gives you the hat, you'll be able to wear as many hats as you want.
So I'd like to know how I could add an "Anti-Spam" thing into this script.
Any help would be appreciated.
|
|
|
| Report Abuse |
|
Inductive
|
  |
| Joined: 28 May 2012 |
| Total Posts: 6480 |
|
|
| 10 Jan 2017 03:16 PM |
| Couldn't you just check the number of hats in the character that touched the part? You could use that to set a limit at three, or five or whatever you want. |
|
|
| Report Abuse |
|
Tagap1234
|
  |
| Joined: 14 Jul 2012 |
| Total Posts: 182 |
|
| |
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 11 Jan 2017 08:33 AM |
if (hit.Parent:findFirstChild("Humanoid") ~= nil and debounce == true and (not hit.Parent:FindFirstChild(script.Parent.Name))) then
|
|
|
| Report Abuse |
|
Tagap1234
|
  |
| Joined: 14 Jul 2012 |
| Total Posts: 182 |
|
| |