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
 

Re: Can someone help me use StringValue correctly

Previous Thread :: Next Thread 
cokePanda is not online. 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
AnonyAnonymous is not online. AnonyAnonymous
Joined: 23 Jun 2013
Total Posts: 6332
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 is not online. 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
AnonyAnonymous is not online. AnonyAnonymous
Joined: 23 Jun 2013
Total Posts: 6332
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
CTServant001 is not online. CTServant001
Joined: 01 Feb 2013
Total Posts: 211
26 Jul 2014 06:28 AM
You have 2 things with same name, try changing the local hatt to a different name.
Report Abuse
CTServant001 is not online. CTServant001
Joined: 01 Feb 2013
Total Posts: 211
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 is not online. 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 is not online. cokePanda
Joined: 30 Dec 2008
Total Posts: 1901
26 Jul 2014 06:33 AM
It's all there... :/
Report Abuse
CTServant001 is not online. CTServant001
Joined: 01 Feb 2013
Total Posts: 211
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 is not online. cokePanda
Joined: 30 Dec 2008
Total Posts: 1901
26 Jul 2014 06:40 AM
hatt = script.Parent.Value.Value

Value = HeadP
Report Abuse
CTServant001 is not online. CTServant001
Joined: 01 Feb 2013
Total Posts: 211
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 is not online. 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 is not online. 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 is not online. cokePanda
Joined: 30 Dec 2008
Total Posts: 1901
26 Jul 2014 06:44 AM
alij, That won't make any difference.
Report Abuse
alij12 is not online. 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 is not online. 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 is not online. 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 is not online. cokePanda
Joined: 30 Dec 2008
Total Posts: 1901
26 Jul 2014 07:00 AM
Same error...
Report Abuse
alij12 is not online. 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
VerifiedName is not online. VerifiedName
Joined: 26 Jul 2009
Total Posts: 4534
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 is not online. cokePanda
Joined: 30 Dec 2008
Total Posts: 1901
26 Jul 2014 07:10 AM
That works :)

Thanks a lot Scripting Helpers.
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