cokePanda
|
  |
| Joined: 30 Dec 2008 |
| Total Posts: 1901 |
|
|
| 26 Jul 2014 06:19 AM |
function onClicked() local plr = game.Players.LocalPlayer local hatt = script.Parent.Value.Value if plr.Character:FindFirstChild("hatt") then -- error here, but IDK how to use values in find first child... print("Hat exists") else if plr.Character:FindFirstChild("hatt") == nil then -- error here, but IDK how to use values in find first child... wait() game.Lighting.hatt:Clone().Parent = plr.Character print("Equipped hat") end end end
script.Parent.MouseButton1Click:connect(onClicked)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- Value is inside the button (Button>Value.Value) -- Script is inside the button (Button>Script)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Output:
11:40:05.190 - hatt is not a valid member of Lighting 11:40:05.191 - Script 'Players.Player1.PlayerGui.ScreenGui.Frame.TextButton.LocalS', Line 9 11:40:05.192 - Stack End |
|
|
| Report Abuse |
|
|
|
| 26 Jul 2014 06:21 AM |
| Remove the quotation marks around "hatt" or else it will consider it a string instead of a variable. |
|
|
| Report Abuse |
|
|
cokePanda
|
  |
| Joined: 30 Dec 2008 |
| Total Posts: 1901 |
|
|
| 26 Jul 2014 06:24 AM |
But then wouldn't it be read this way:
if plr.Character:FindFirstChild(WhateverTheValueIsSetTo)
?
Instead of:
if plr.Character:FindFirstChild("WhateverTheValueIsSetTo")
? |
|
|
| Report Abuse |
|
|
|
| 26 Jul 2014 06:27 AM |
| It's going to retrieve the value of the object in string-form because it's a StringValue. |
|
|
| Report Abuse |
|
|
|
| 26 Jul 2014 06:28 AM |
| You have 2 things with same name, try changing the local hatt to a different name. |
|
|
| Report Abuse |
|
|
|
| 26 Jul 2014 06:30 AM |
| Also the output says the script just can't find the hatt you placed in lighting so make sure the hat is there before you clone it. |
|
|
| Report Abuse |
|
|
cokePanda
|
  |
| Joined: 30 Dec 2008 |
| Total Posts: 1901 |
|
|
| 26 Jul 2014 06:31 AM |
I still get:
12:31:24.897 - wot is not a valid member of Lighting 12:31:24.898 - Script 'Players.Player1.PlayerGui.ScreenGui.Frame.TextButton.LocalS', Line 9 12:31:24.900 - Stack End
|
|
|
| Report Abuse |
|
|
cokePanda
|
  |
| Joined: 30 Dec 2008 |
| Total Posts: 1901 |
|
| |
|
|
| 26 Jul 2014 06:35 AM |
| Do you have a object named hatt in lighting? that is what the error is saying. |
|
|
| Report Abuse |
|
|
cokePanda
|
  |
| Joined: 30 Dec 2008 |
| Total Posts: 1901 |
|
|
| 26 Jul 2014 06:40 AM |
hatt = script.Parent.Value.Value
Value = HeadP |
|
|
| Report Abuse |
|
|
|
| 26 Jul 2014 06:41 AM |
?
are you looking into lighting for a hatt or did you mean to have it defied with the local hatt = script.Parent.Value.Value? |
|
|
| Report Abuse |
|
|
alij12
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 1204 |
|
|
| 26 Jul 2014 06:42 AM |
.Value.Value
Change the name of your value to something else, not Value. |
|
|
| Report Abuse |
|
|
cokePanda
|
  |
| Joined: 30 Dec 2008 |
| Total Posts: 1901 |
|
|
| 26 Jul 2014 06:42 AM |
I meant to have it defined :/
Isn't that what I have done though? |
|
|
| Report Abuse |
|
|
cokePanda
|
  |
| Joined: 30 Dec 2008 |
| Total Posts: 1901 |
|
|
| 26 Jul 2014 06:44 AM |
| alij, That won't make any difference. |
|
|
| Report Abuse |
|
|
alij12
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 1204 |
|
|
| 26 Jul 2014 06:44 AM |
| Yes it will, if the name of your string value is "Value", then it will throw errors. |
|
|
| Report Abuse |
|
|
cokePanda
|
  |
| Joined: 30 Dec 2008 |
| Total Posts: 1901 |
|
|
| 26 Jul 2014 06:48 AM |
| Well, if that's the "CASE" then, no that did not fix anything. |
|
|
| Report Abuse |
|
|
alij12
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 1204 |
|
|
| 26 Jul 2014 06:52 AM |
try this
function onClicked() local plr = game.Players.LocalPlayer local hatt = script.Parent["New name of value here"].Value if plr.Character:FindFirstChild(hatt) then print("Hat exists") else if not plr.Character:FindFirstChild(hatt) then wait() game.Lighting.hatt:Clone().Parent = plr.Character print("Equipped hat") end end end
script.Parent.MouseButton1Click:connect(onClicked) |
|
|
| Report Abuse |
|
|
cokePanda
|
  |
| Joined: 30 Dec 2008 |
| Total Posts: 1901 |
|
| |
|
alij12
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 1204 |
|
|
| 26 Jul 2014 07:02 AM |
function onClicked() local plr = game.Players.LocalPlayer local hatt = script.Parent["New name of value here"].Value if plr.Character:FindFirstChild(hatt) then print("Hat exists") else if not plr.Character:FindFirstChild(hatt) then wait() newHat = game.Lighting:findFirstChild(hatt) if newHat ~= nil then newHat2 = newHat:clone() newHat2.Parent = plr.Character print("Equipped hat") else print("Hatt isnt in lighting") end end end end
script.Parent.MouseButton1Click:connect(onClicked) |
|
|
| Report Abuse |
|
|
|
| 26 Jul 2014 07:09 AM |
"Yes it will, if the name of your string value is "Value", then it will throw errors."
uh no, no it wont.
|
|
|
| Report Abuse |
|
|
cokePanda
|
  |
| Joined: 30 Dec 2008 |
| Total Posts: 1901 |
|
|
| 26 Jul 2014 07:10 AM |
That works :)
Thanks a lot Scripting Helpers. |
|
|
| Report Abuse |
|
|