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 » Scripters
Home Search
 

Re: Nil value everythime -.-

Previous Thread :: Next Thread 
supermisstruth is not online. supermisstruth
Joined: 11 Oct 2009
Total Posts: 158
12 Sep 2015 10:38 PM
everytime i try to change a script it says cant index a nil value !
script :
brick = script.Parent
inArea = false
redBrick = Instance.new("Part", workspace)
redBrick.CanCollide = false
redBrick.Transparency = 1
redBrick.Position = Vector3.new(-193, 2.5, 9)
redBrick.BrickColor = BrickColor.new(21)
redBrick.Size = Vector3.new(4, 1, 6)
redBrick.Anchored = true

function appearBrick()
redBrick.Transparency = 0
redBrick.CanCollide =true
end

function dissapearBrick()
redBrick.Transparency = 1
redBrick.CanCollide =false
end

brick.Touched:connect(function(hit)
inArea = true
print("In Area")
human = hit.Parent:FindFirstChild("Humanoid")
local char = game.Players:GetPlayerFromCharacter(human)
if human then
human.Parent.area=1
print("inside = true")
print("Human")
appearBrick()
end
end)

brick.TouchEnded:connect(function()
human.Parent.area=0
print("inside = false")
inArea=false
print("Not In Area")
dissapearBrick()
end)

-----------------
Why does this happen????
Report Abuse
lego555444 is not online. lego555444
Joined: 21 Sep 2008
Total Posts: 1383
12 Sep 2015 11:11 PM
which line
Report Abuse
supermisstruth is not online. supermisstruth
Joined: 11 Oct 2009
Total Posts: 158
12 Sep 2015 11:16 PM
35
Report Abuse
lego555444 is not online. lego555444
Joined: 21 Sep 2008
Total Posts: 1383
12 Sep 2015 11:33 PM
quote that line below
Report Abuse
SoapyDishy is not online. SoapyDishy
Joined: 31 Aug 2015
Total Posts: 2169
12 Sep 2015 11:35 PM
Is this the full script? If not, then paste the rest
Report Abuse
supermisstruth is not online. supermisstruth
Joined: 11 Oct 2009
Total Posts: 158
12 Sep 2015 11:46 PM
full script(only added a intvalue when a player join to show if hes in the area or not)
line 35:
human.Parent.area=0
Report Abuse
SoapyDishy is not online. SoapyDishy
Joined: 31 Aug 2015
Total Posts: 2169
12 Sep 2015 11:47 PM
don't u mean

human.Parent.area.Value = 0

if this is an IntVzlue?
Report Abuse
supermisstruth is not online. supermisstruth
Joined: 11 Oct 2009
Total Posts: 158
13 Sep 2015 12:00 AM
okay fixed that then after it says :
00:59:35.503 - area is not a valid member of Model
00:59:35.503 - Script 'Workspace.ProxBox.Script', Line 27
00:59:35.503 - Stack End
line 27 :
human.Parent.area.Value=1
Report Abuse
SoapyDishy is not online. SoapyDishy
Joined: 31 Aug 2015
Total Posts: 2169
13 Sep 2015 12:02 AM
Where is the IntVzlue located
Report Abuse
supermisstruth is not online. supermisstruth
Joined: 11 Oct 2009
Total Posts: 158
13 Sep 2015 12:05 AM
the intvalue is located exactly at :
game.Players.Player.area -- area is IntValue
Report Abuse
SoapyDishy is not online. SoapyDishy
Joined: 31 Aug 2015
Total Posts: 2169
13 Sep 2015 12:10 AM
Then why isn't it a valid member of model. Show the snippet of code where it's erroring
Report Abuse
supermisstruth is not online. supermisstruth
Joined: 11 Oct 2009
Total Posts: 158
13 Sep 2015 12:11 AM

u want me to show which code ._.
Report Abuse
supermisstruth is not online. supermisstruth
Joined: 11 Oct 2009
Total Posts: 158
13 Sep 2015 12:12 AM
I mean the leaderstats script looks fine:

-- Made by supermisstruth aka trainsis
game.Players.PlayerAdded:connect(function (player)
local stats = Instance.new("IntValue", player)
stats.Name = "leaderstats"
local area = Instance.new("IntValue", player)
area.Name = "area"
area.Value = 0
local point = Instance.new("IntValue", stats)
point.Value = 150
point.Name = "Robux"

end)
Report Abuse
supermisstruth is not online. supermisstruth
Joined: 11 Oct 2009
Total Posts: 158
13 Sep 2015 12:25 AM
ughh
Report Abuse
SoapyDishy is not online. SoapyDishy
Joined: 31 Aug 2015
Total Posts: 2169
13 Sep 2015 12:27 AM
human.Parent.leaderstats.area.Value = 0
Report Abuse
Link5659 is not online. Link5659
Joined: 04 Jun 2012
Total Posts: 4525
13 Sep 2015 12:27 AM
I have no idea right now ive had about 6 hours of sleep in 32 hours awake but try fixing this for starters

redBrick = Instance.new("Part", workspace) --this :3
Report Abuse
ShungTzu is not online. ShungTzu
Joined: 14 Jun 2014
Total Posts: 959
13 Sep 2015 12:38 AM
"
Why does this happen????
"

Because GetPlayerFromCharacter returns a player in game.Players, only if you pass a player's character in workspace to it, and the parent of humanoid is a character, but you're passing a Humanoid to GetPlayerFromCharacter and looking in a character for area(which is in a player).

Replace this

brick.Touched:connect(function(hit)
inArea = true
print("In Area")
human = hit.Parent:FindFirstChild("Humanoid")
local char = game.Players:GetPlayerFromCharacter(human)
if human then
human.Parent.area=1
print("inside = true")
print("Human")
appearBrick()
end
end)

with this


brick.Touched:connect(function(hit)
inArea = true
print("In Area")
local char=hit.Parent
local human = char:FindFirstChild("Humanoid")
local player= game.Players:GetPlayerFromCharacter(char)
if human and player then
player.Parent.area=1
print("inside = true")
print("Human")
appearBrick()
end
end)
.
I hope you pay attention to the difference.
Report Abuse
ShungTzu is not online. ShungTzu
Joined: 14 Jun 2014
Total Posts: 959
13 Sep 2015 12:42 AM
Sorry,
player.area=1
, not
player.Parent.area=1
.
Report Abuse
supermisstruth is not online. supermisstruth
Joined: 11 Oct 2009
Total Posts: 158
13 Sep 2015 12:53 AM
humm..
01:52:48.849 - Workspace.ProxBox.Script:36: attempt to index global 'player' (a nil value)
script:
brick = script.Parent
inArea = false
redBrick = Instance.new("Part", workspace)
redBrick.CanCollide = false
redBrick.Transparency = 1
redBrick.Position = Vector3.new(-193, 2.5, 9)
redBrick.BrickColor = BrickColor.new(21)
redBrick.Size = Vector3.new(4, 1, 6)
redBrick.Anchored = true

function appearBrick()
redBrick.Transparency = 0
redBrick.CanCollide =true
end

function dissapearBrick()
redBrick.Transparency = 1
redBrick.CanCollide =false
end

brick.Touched:connect(function(hit)
inArea = true
print("In Area")
local char=hit.Parent
local human = char:FindFirstChild("Humanoid")
player= game.Players:GetPlayerFromCharacter(char)
if human and player then
player.area.Value=1
print("inside = true")
print("Human")
appearBrick()
end
end)

brick.TouchEnded:connect(function()
player.area.Value=0
print("inside = false")
inArea=false
print("Not In Area")
dissapearBrick()
end)
line 36:
player.area.Value=0
Report Abuse
supermisstruth is not online. supermisstruth
Joined: 11 Oct 2009
Total Posts: 158
13 Sep 2015 12:57 AM
whats wrong :/
Report Abuse
ShungTzu is not online. ShungTzu
Joined: 14 Jun 2014
Total Posts: 959
13 Sep 2015 01:24 PM
Something other than a player's Character is touching and then firing TouchEnded.

local char=hit.Parent
local human = char:FindFirstChild("Humanoid")
local player= game.Players:GetPlayerFromCharacter(char)--made "player" local to this function
if human and player then
player.area.Value=1
print("inside = true")
print("Human")
appearBrick()
end
end)

brick.TouchEnded:connect(function(hit)--get the part so you can do something to a player if the thing that stopped touching is part of a player's Character
local char=hit.Parent
local human = char:FindFirstChild("Humanoid")
local player= game.Players:GetPlayerFromCharacter(char)
if human and player then
player.area.Value=0
print("inside = false")
inArea=false
print("Not In Area")
dissapearBrick()
end
end)
Report Abuse
supermisstruth is not online. supermisstruth
Joined: 11 Oct 2009
Total Posts: 158
13 Sep 2015 02:39 PM
okay now my script work :)
but now i made a guy that if the area value == 1 then it will show up and if its not equal to 1 it will dissapear and the script is not working ._. why??
script :
local player = game.Players.LocalPlayer
local shop = player.PlayerGui:WaitForChild("ShopGUI").MainGui


script.Parent.MouseButton1Click:connect(function ()
shop.Visible = not shop.Visible
end)

if(player.area.Value==0) then
shop.Visible = false
player.PlayerGui:WaitForChild("Buttons").Frame.Visible = false
print("Invisible")
end

if(player.area.Value==1)then -- when in the area it will show up the Gui
shop.Visible = true
player.PlayerGui:WaitForChild("Buttons").Frame.Visible = true
shop.Visible = not shop.Visible
print("-------")
print("Visible")
print("-------")
end
Report Abuse
supermisstruth is not online. supermisstruth
Joined: 11 Oct 2009
Total Posts: 158
13 Sep 2015 02:55 PM
anyone?
Report Abuse
supermisstruth is not online. supermisstruth
Joined: 11 Oct 2009
Total Posts: 158
13 Sep 2015 03:31 PM
bumpity
Report Abuse
Link5659 is not online. Link5659
Joined: 04 Jun 2012
Total Posts: 4525
13 Sep 2015 04:35 PM
if(player.area.Value==0) then
shop.Visible = false
player.PlayerGui:WaitForChild("Buttons").Frame.Visible = false
print("Invisible")
elseif(player.area.Value==1)then -- when in the area it will show up the Gui
shop.Visible = true
player.PlayerGui:WaitForChild("Buttons").Frame.Visible = true
shop.Visible = not shop.Visible
print("-------")
print("Visible")
print("-------")
end
--try this no idea if it will work :/
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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