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 » Scripting Helpers
Home Search
 

Tool Problem

Previous Thread :: Next Thread 
liavt is not online. liavt
Joined: 12 Mar 2009
Total Posts: 1241
11 Aug 2012 10:35 AM
tool = script.Parent
local human = Game.Players.LocalPlayer
local person = workspace:FindFirstChild (human.Name)

function B()
function A()
local targetPos = Mouse.Target
local t = targetPos
local h = targetPos:FindFirstChild("D")
local i = targetPos:FindFirstChild("I")
local hu = t:FindFirstChild ("Humanoid")
if d == false then
wait(1)
elseif d == true then
human.Torso.Anchored = true
tool.ScreenGui.UI.Image.Image = (i.Value)
if hu == true then
tool.ScreenGui.HI.Visible = true
tool.ScreenGui.HI.H.Text = ("Health:"..hu.Health.."/"..hu.MaxHealth)
tool.ScreenGui.HI.L.Text = ("Level:"..human.Level.Value)
else
tool.ScreenGui.HI.Visible = false
end
tool.ScreenGui.Frame.D.Text = (h.Value)
tool.ScreenGui.Frame.N.Text = t.Name
local i = tool.ScreenGui:Clone()
i.Parent = human.PlayerGui
end
end
end


tool.Activated:connect(A)
tool.Equipped:connect(B)




Output says 'Attempt to call a nil value' when I click on an object
Report Abuse
HilariousDwarf is not online. HilariousDwarf
Joined: 20 Aug 2010
Total Posts: 2020
11 Aug 2012 10:38 AM
You need to define "Mouse". I wrote this quickly so it may not work

function A(Mouse)
local targetPos = Mouse.Target
local t = targetPos
local h = targetPos:FindFirstChild("D")
local i = targetPos:FindFirstChild("I")
local hu = t:FindFirstChild ("Humanoid")
if d == false then
wait(1)
elseif d == true then
human.Torso.Anchored = true
tool.ScreenGui.UI.Image.Image = (i.Value)
if hu == true then
tool.ScreenGui.HI.Visible = true
tool.ScreenGui.HI.H.Text = ("Health:"..hu.Health.."/"..hu.MaxHealth)
tool.ScreenGui.HI.L.Text = ("Level:"..human.Level.Value)
else
tool.ScreenGui.HI.Visible = false
end
tool.ScreenGui.Frame.D.Text = (h.Value)
tool.ScreenGui.Frame.N.Text = t.Name
local i = tool.ScreenGui:Clone()
i.Parent = human.PlayerGui
end
end
end


tool.Equipped:connect(function(mouse)
tool.Activated:connect(function() A(mouse) end)
end)
Report Abuse
liavt is not online. liavt
Joined: 12 Mar 2009
Total Posts: 1241
11 Aug 2012 10:56 AM
Nothing happens when I click....


No output.
Report Abuse
HilariousDwarf is not online. HilariousDwarf
Joined: 20 Aug 2010
Total Posts: 2020
11 Aug 2012 10:57 AM
Is it a LocalScript?
Report Abuse
liavt is not online. liavt
Joined: 12 Mar 2009
Total Posts: 1241
11 Aug 2012 10:58 AM
Yes.
Report Abuse
HilariousDwarf is not online. HilariousDwarf
Joined: 20 Aug 2010
Total Posts: 2020
11 Aug 2012 10:58 AM
There's the problem. Seems like LocalScripts don't like mouses anymore.
Report Abuse
liavt is not online. liavt
Joined: 12 Mar 2009
Total Posts: 1241
11 Aug 2012 11:00 AM
So put it in a reguler script?
Report Abuse
HilariousDwarf is not online. HilariousDwarf
Joined: 20 Aug 2010
Total Posts: 2020
11 Aug 2012 11:03 AM
It probably won't work but try it anyway.
Report Abuse
Jlobblet is not online. Jlobblet
Joined: 05 Sep 2010
Total Posts: 587
11 Aug 2012 11:04 AM
You can't access the mouse in a regular script. I'll see if I can debug...

~if not ok then return end
Report Abuse
liavt is not online. liavt
Joined: 12 Mar 2009
Total Posts: 1241
11 Aug 2012 11:08 AM
So if it doesn't work in a reguler script..
or a localscript....

So where does it work!
Report Abuse
liavt is not online. liavt
Joined: 12 Mar 2009
Total Posts: 1241
11 Aug 2012 11:43 AM
Bump
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
11 Aug 2012 12:03 PM
> There's the problem. Seems like LocalScripts don't like mouses anymore.

What... they work better in LocalScripts (if not only)...

† KMXD †
Report Abuse
liavt is not online. liavt
Joined: 12 Mar 2009
Total Posts: 1241
11 Aug 2012 12:09 PM
So how do I fix it?
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
11 Aug 2012 12:13 PM
Not sure if it'd make a difference, but put this in a LocalScript:

d = false
tool = script.Parent
tool.Equipped:connect(function(Mouse)
Mouse.Button1Down:connect(function()
local targetPos = Mouse.Target
local t = targetPos
local h = targetPos:FindFirstChild("D")
local i = targetPos:FindFirstChild("I")
local hu = t:FindFirstChild("Humanoid")
if d == false then
wait(1)
elseif d == true then
human.Torso.Anchored = true
tool.ScreenGui.UI.Image.Image = (i.Value)
if hu == true then
tool.ScreenGui.HI.Visible = true
tool.ScreenGui.HI.H.Text = ("Health:"..hu.Health.."/"..hu.MaxHealth)
tool.ScreenGui.HI.L.Text = ("Level:"..human.Level.Value)
else
tool.ScreenGui.HI.Visible = false
end
tool.ScreenGui.Frame.D.Text = (h.Value)
tool.ScreenGui.Frame.N.Text = t.Name
local i = tool.ScreenGui:Clone()
i.Parent = human.PlayerGui
end
end
end
end)
end)

? There were some confusing things...

† KMXD †
Report Abuse
liavt is not online. liavt
Joined: 12 Mar 2009
Total Posts: 1241
11 Aug 2012 12:21 PM
tool = script.Parent
tool.Equipped:connect(function(Mouse)
Mouse.Button1Down:connect(function()
local targetPos = Mouse.Target
local t = targetPos
local h = targetPos:FindFirstChild("D")
local i = targetPos:FindFirstChild("I")
local hu = t:FindFirstChild("Humanoid")
if d == false then
wait(1)
elseif d == true then
human.Torso.Anchored = true
tool.ScreenGui.UI.Image.Image = (i.Value)
if hu == true then
tool.ScreenGui.HI.Visible = true
tool.ScreenGui.HI.H.Text = ("Health:"..hu.Health.."/"..hu.MaxHealth)
tool.ScreenGui.HI.L.Text = ("Level:"..human.Level.Value)
else
tool.ScreenGui.HI.Visible = false
end
tool.ScreenGui.Frame.D.Text = (h.Value)
tool.ScreenGui.Frame.N.Text = t.Name
local i = tool.ScreenGui:Clone()
i.Parent = human.PlayerGui
end
end)
end)



Thats your script after fixing a few errors. And also it doesn't work...
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
11 Aug 2012 12:40 PM
I merely skimmed the script, but I had a "d = false" up there. You didn't define tool or d before, so I'm not sure what the problem is.

† KMXD †
Report Abuse
liavt is not online. liavt
Joined: 12 Mar 2009
Total Posts: 1241
11 Aug 2012 02:07 PM
I don't need to define it.


Every block has 2 stringvalues:

D is the first one
I is the second one

When I click on a brick, It will find the two values and a gui pops up. I has a link to a decal, and a picture appears. And D has the description. If you look closely, you can see the script using D and I to change stuff.

Plus, there all capital.
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
11 Aug 2012 02:16 PM
Try this?

local tool = script.Parent
tool.Equipped:connect(function(Mouse)
local human = script.Parent.Parent.Parent
Mouse.Button1Down:connect(function()
local targetPos = Mouse.Target
local h = targetPos:FindFirstChild("D")
local i = targetPos:FindFirstChild("I")
local hu = targetPos:FindFirstChild("Humanoid")
if ((not h) or (not i)) then return; end
human.Character.Torso.Anchored = true end
tool.ScreenGui.UI.Image.Image = i.Value
if (hu) then
tool.ScreenGui.HI.Visible = true
tool.ScreenGui.HI.H.Text = "Health:"..hu.Health.."/"..hu.MaxHealth
tool.ScreenGui.HI.L.Text = "Level:"..human.Level.Value
else
tool.ScreenGui.HI.Visible = false
end
tool.ScreenGui.Frame.D.Text = h.Value
tool.ScreenGui.Frame.N.Text = t.Name
local i = tool.ScreenGui:Clone()
i.Parent = human.PlayerGui
end)
end)
Report Abuse
Kirbykid02 is not online. Kirbykid02
Joined: 18 May 2009
Total Posts: 2671
11 Aug 2012 02:18 PM
Simple solution : Put a wait(2) in front of it all.
Report Abuse
liavt is not online. liavt
Joined: 12 Mar 2009
Total Posts: 1241
11 Aug 2012 02:32 PM
When equiped:
14:32:09 - Players.Player.Backpack.Examine.LocalScript:12: attempt to index global 'i' (a nil value)
14:32:09 - Script "Players.Player.Backpack.Examine.LocalScript", Line 12
14:32:09 - stack end
14:32:09 - Disconnected event because of exception
When I click:
14:32:17 - Players.Player.Backpack.Examine.LocalScript:5: attempt to index upvalue 'Mouse' (a thread value)
14:32:17 - Script "Players.Player.Backpack.Examine.LocalScript", Line 5
14:32:17 - stack end
14:32:17 - Disconnected event because of exception
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
11 Aug 2012 02:39 PM
Rewrote from scratch:

wait(2);
local tool = script.Parent;
local plr = tool.Parent.Parent;
local gui = tool.ScreenGui;

tool.Equipped:connect(function (mouse)
mouse.Button1Down:connect(function ()
local targ = mouse.TargetPos;
local dval = targ:findFirstChild("D");
local ival = targ:findFirstChild("I");
local hum = targ:findfFirstChild("Humanoid");
if ((not dval) or (not ival)) then gui.Parent = tool; return; end
if ((plr.Character) and (plr.Character.Torso)) then plr.Character.Torso.Anchored = true; end
gui.UI.Image.Image = i.Value;
if (hum) then
gui.HI.Visible = true;
gui.HI.H.Text = "Health: "..hum.Health.."/"..hum.MaxHealth;
gui.HI.L.Text = "Level: "..hum.Level.Value;
else
gui.HI.Visible = false;
end
gui.Frame.D.Text = dval.Value;
gui.Frame.N.Text = targ.Name;
gui.Parent = plr.PlayerGui;
end);
end);
Report Abuse
liavt is not online. liavt
Joined: 12 Mar 2009
Total Posts: 1241
11 Aug 2012 02:46 PM
Whenever I click,

14:44:50 - Players.Player.Backpack.Examine.LocalScript:14: attempt to index global 'i' (a nil value)
14:44:50 - Script "Players.Player.Backpack.Examine.LocalScript", Line 14
14:44:50 - stack end
14:44:50 - Disconnected event because of exception


How do you change the image of a imagelabel? Because according to the output, its not a string.
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
11 Aug 2012 02:48 PM
gui.UI.Image.Image = i.Value;
Change to:
gui.UI.Image.Image = ival.Value;
Report Abuse
liavt is not online. liavt
Joined: 12 Mar 2009
Total Posts: 1241
11 Aug 2012 02:51 PM
It works! Thanks
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
11 Aug 2012 02:54 PM
:D yw
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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