|
| 20 May 2014 09:50 PM |
The script includes filters which are scanned upon Touched(hit), if none of the classNames match the hit className then it continues upon the script which will prevent errors. However one thing gets through which is "Hat" that breaks the script...
Here is the script;
function onTouched(hit) if hit.className == "Hat" then return end if hit.className == "Tool" then return end if hit.Name == "Part" then return end if hit.className == "Explosion" then return end if hit.className == "Sparkles" then return end if hit.className == "Fire" then return end if hit.className == "Smoke" then return end if hit.className == "ForceField" then return end hit.Parent.Head.face:Remove() Instance.new('Decal', hit.Parent.Head) hit.Parent.Head.Decal.Texture = "http://www.roblox.com/asset/?id=30022519" hit.Parent.Head.Decal.Name = "face" end
Workspace.FaceChanger.Touched:connect(onTouched)
The Errors I get inside the console;
19:46:23.095 - Head is not a valid member of Hat |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 20 May 2014 09:59 PM |
Bruh, non physical items like explosion sparkles fir smoke and forcefield cannot be touched, no need for that. returning causes a lot of lag because it expects some sort of value, but then you return nothing so it all gets stored up. Not all parts of the body are normal parts. You could just change the Textuire of the current dcal, no need to delete it a bunch. And you don't even need the filter, you could just have to if statement for checking a humanoid or something but here you go;
game.Workspace.FaceChanger.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") ~= nil then if hit:IsA("Hat") then print("Nu") elseif hit:IsA("Tool") then print("Nu") elseif hit:IsA("BasePart") then print("Nu") hit.Parent.Head.face.Texture = "http://www.roblox.com/asset/?id=30022519" end end end) |
|
|
| Report Abuse |
|
|
| |
|
|
| 20 May 2014 10:01 PM |
@Goulstem Thank you, but scripts like that are too complex for me to understand, so I just take the longer route. |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 20 May 2014 10:05 PM |
And wait a minute, if you're not allowing parts to touch it then this won't work at all, you have to allow something to touch it.. If you're just trying tyo get the effect of no tools and hats touching then here;
local db = false
game.Workspace.FaceChanger.Touched:connect(function(hit) if db == false then db = true if hit.Parent:FindFirstChild("Humanoid") ~= nil then if hit.Name == "Handle" then print("Cannot activate by hats or tools bruh") else hit.Parent.Head.face.Texture = "http://www.roblox.com/asset/?id=30022519" db = false end end end end) |
|
|
| Report Abuse |
|
|
|
| 20 May 2014 10:08 PM |
@Goulstem I already knew that if Parts were included from the filter it would break, so instead of "className" I picked "Name".
className defines it's Class property. Name defines what it's current name is. |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 20 May 2014 10:12 PM |
| Yeah I know the difference between them but I didn't see that, haha ok den, you can still use the one I just supplied though. I put if it's name is handle which is the part with a mesh that is visible in hats, hat it'self is a non physical object so it couldn't activate a touched event either. |
|
|
| Report Abuse |
|
|
|
| 20 May 2014 10:15 PM |
BTW, you never answered my question in the first place... only fixed it.
I do this so I can understand a bit more about how RBLX.Lua works. |
|
|
| Report Abuse |
|
|
|
| 20 May 2014 10:16 PM |
Here is my face changer script for onChatted events.
asset = "http://www.roblox.com/Thumbs/Asset.ashx?Width=110&Height=110&AssetID="
local chat = function(msg, speaker) if msg:sub(1, 5):lower() == "face:" then if not tonumber(msg:sub(6)) then print(msg:sub(6).." is not numeric.") else local id = tonumber(msg:sub(6)) if asset..id ~= nil then local face = speaker.Character.Head:FindFirstChild("face") if face ~= nil then face.Texture = asset..id end end end elseif msg:sub(1, 4):lower() == "help" then local m = Instance.new("Message", speaker.PlayerGui) m.Text = "Face:ID to change faces, minigame help not provided." wait(3) m:remove() end end
local plr = function(player) repeat wait() until player.Character player.Chatted:connect(function(msg, speaker) chat(msg, player) end) end
game.Players.PlayerAdded:connect(plr) |
|
|
| Report Abuse |
|
|