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 » Scripters
Home Search
 

Re: Table

Previous Thread :: Next Thread 
RobloxAssociated is not online. RobloxAssociated
Joined: 30 Oct 2011
Total Posts: 449
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
RobloxAssociated is not online. RobloxAssociated
Joined: 30 Oct 2011
Total Posts: 449
08 Oct 2015 02:06 PM
Output:
Players.Player.PlayerGui.Interaction:6: bad argument #2 to 'find' (string expected, got no value)
Report Abuse
GlacierGames is not online. GlacierGames
Joined: 22 Oct 2011
Total Posts: 1549
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 is not online. 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
RobloxAssociated is not online. RobloxAssociated
Joined: 30 Oct 2011
Total Posts: 449
08 Oct 2015 02:10 PM
Thank you guys :P
Report Abuse
GlacierGames is not online. GlacierGames
Joined: 22 Oct 2011
Total Posts: 1549
08 Oct 2015 02:11 PM
Welcome.


[http://www.roblox.com/Naruto-Shippuuden-Sasuke-Theme-1-item?id=159498348]
Report Abuse
GlacierGames is not online. GlacierGames
Joined: 22 Oct 2011
Total Posts: 1549
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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