|
| 08 Oct 2015 02:05 PM |
The mouse clicks on an object and the script determines if the objects name is found in the table "objects". I haven't scripted in quite a while.
player = script.Parent.Parent mouse = player:GetMouse() objects = {"Fridge"} mouse.Button1Down:connect(function() local find = mouse.Target if find.Parent.Name == string.find(table.concat(objects,' ')) then --< Problem print"yay" end end)
How to fix line 6? > if find.Parent.Name == string.find(table.concat(objects,' ')) then |
|
|
| Report Abuse |
|
|
|
| 08 Oct 2015 02:06 PM |
Output: Players.Player.PlayerGui.Interaction:6: bad argument #2 to 'find' (string expected, got no value) |
|
|
| Report Abuse |
|
|
|
| 08 Oct 2015 02:08 PM |
player = script.Parent.Parent mouse = player:GetMouse() objects = {"Fridge"}
function check(item) for _,v in pairs (objects) do if v == item then return true end end end mouse.Button1Down:connect(function() local find = mouse.Target if check(find.Parent) then --< Problem print"yay" end end)
-[Reformed Gaming Community]- |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 08 Oct 2015 02:09 PM |
Make sure this is a LocalScript inside somewhere that repliates to the client.
local mouse = game.Players.LocalPlayer:GetMouse(); local objects = {"Fridge"};
mouse.Button1Down:connect(function() if mouse.Target == nil then return end for _,v in next,objects do if v == mouse.Target.Name then print("Yay!"); end end end) |
|
|
| Report Abuse |
|
|
| |
|
|
| 08 Oct 2015 02:11 PM |
Welcome.
[http://www.roblox.com/Naruto-Shippuuden-Sasuke-Theme-1-item?id=159498348] |
|
|
| Report Abuse |
|
|
|
| 08 Oct 2015 02:12 PM |
[http://www.roblox.com/Naruto-Shippuuden-Sasuke-Theme-1-item?id=159498348 http://www.roblox.com/Akatsuki-Theme-item?id=149318510] |
|
|
| Report Abuse |
|
|