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: Help!

Previous Thread :: Next Thread 
StrikerBOY606 is not online. StrikerBOY606
Joined: 25 Oct 2010
Total Posts: 747
10 Apr 2013 07:07 AM
I got the Text Button in the ScreenGui which is located inside the StarterGui. I want it so when the player clicks the button it makes them invisible, problem is, it won't work. Here is the output,

13:06:36.465 - Players.Player1.PlayerGui.AdminGUI.Player OPTIONS.Invisible:4: attempt to get length of local 'c' (a userdata value)

I think it's on line 4 but I don't know what the problem is exactly?!

This script is in a LocalScript:

function click()
local player = game.Players.LocalPlayer
local c = player.Character
for i = 1, #c do
if c[i].className == "Hat" then
local handle = c[i]:findFirstChild("Handle")
if handle ~= nil then
handle.Transparency = 1
c.Torso.Transparency = 1
c.Head.Transparency = 1
c.RightLeg.Transparency = 1
c.LeftLeg.Transparency = 1
c.LeftArm.Transparency = 1
c.RightArm.Transparency = 1
end
end
end
end

script.Parent.MouseButton1Click:connect(click)
Report Abuse
coolikevin22 is not online. coolikevin22
Joined: 21 Feb 2011
Total Posts: 450
10 Apr 2013 07:09 AM
Try using GetPlayerFromCharacter()
Report Abuse
StrikerBOY606 is not online. StrikerBOY606
Joined: 25 Oct 2010
Total Posts: 747
10 Apr 2013 07:14 AM
I tried using it here:
local player = game.Players.LocalPlayer:GetPlayerFromCharacter()

and here:

local c = player:GetPlayerFromCharacter()

Did not work.

Unless I need to put it somewhere else. :P
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
10 Apr 2013 07:28 AM
Why... why would GetPlayerFromCharacter be a member of the Character?

In the object browser and Wiki, you can see it is a member of Players.

http://wiki.roblox.com/index.php/GetPlayerFromCharacter_(Method)

However, these things will not solve your problem. You are trying to get the length of a userdata (the character). You really want to get the length of the table of objects in the character.

Change the local c line to this:

local c = player.Character:GetChildren()
Report Abuse
StrikerBOY606 is not online. StrikerBOY606
Joined: 25 Oct 2010
Total Posts: 747
10 Apr 2013 07:35 AM
Fixed, thanks btw!
Report Abuse
StrikerBOY606 is not online. StrikerBOY606
Joined: 25 Oct 2010
Total Posts: 747
10 Apr 2013 07:49 AM
[bump]
Here is my updated one, nothing appears in the output. All the hats on my character disappear but my head, torso etc don't.

function clk()
local player = game.Players.LocalPlayer
local c = player.Character:GetChildren()
for i = 1, #c do
if c[i].className == "Hat" then
local handle = c[i]:findFirstChild("Handle")
if handle then
handle.Transparency = 1
local head = c[i]:findFirstChild("Head")
if head then
head.Transparency = 1
local LA = c[i]:findFirstChild("Left Arm")
if LA then
LA.Transparency = 1
local RA = c[i]:findFirstChild("Right Arm")
if RA then
RA.Transparency = 1
local LL = c[i]:findFirstChild("Left Leg")
if LL then
LL.Transparency = 1
local RL = c[i]:findFirstChild("Right Leg")
if RL then
RL.Transparency = 1
local torso = c[i]:findFirstChild("Torso")
if torso then
torso.Transparency = 1
end
end
end
end
end
end
end
end
end
end



script.Parent.MouseButton1Click:connect(clk)
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
10 Apr 2013 07:51 AM
You can't just have a heap of ends on like that. end something when it no longer needs to apply.

if RA then
RA.Transparency = 1
local LL = c[i]:findFirstChild("Left Leg")
end------------------------------------------------
if LL then
LL.Transparency = 1
local RL = c[i]:findFirstChild("Right Leg")
end---------------------------------------------------
if RL then
RL.Transparency = 1
local torso = c[i]:findFirstChild("Torso")
end---------------------------------------------------
Report Abuse
StrikerBOY606 is not online. StrikerBOY606
Joined: 25 Oct 2010
Total Posts: 747
10 Apr 2013 07:52 AM
Oh, ok.
Report Abuse
StrikerBOY606 is not online. StrikerBOY606
Joined: 25 Oct 2010
Total Posts: 747
10 Apr 2013 08:18 AM
I fixed it and made it shorter, all I need was make it find a classname that is equal to part then make it's transparency 0.
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