|
| 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 |
|
|
|
| 10 Apr 2013 07:09 AM |
| Try using GetPlayerFromCharacter() |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
| |
|
|
| 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 |
|
|
|
| 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 |
|
|
| |
|
|
| 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 |
|
|