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: Help with if statement ?

Previous Thread :: Next Thread 
ReverseUniverse is not online. ReverseUniverse
Joined: 23 Jan 2015
Total Posts: 1118
24 Feb 2015 12:04 PM
player = game.Players:FindFirstChild()
local StringValue = Instance.new("StringValue", player)
StringValue.Name = "Alive"

if player:FindFirstChild("Alive") then
points = player.leaderstats.Points
points.Value = points.Value + 250
end

--Check if player has StringValue named "Alive" if so then add onto players leaderstats points by 250

.
Report Abuse
ReverseUniverse is not online. ReverseUniverse
Joined: 23 Jan 2015
Total Posts: 1118
24 Feb 2015 12:06 PM
bump-1
Report Abuse
SLY3 is not online. SLY3
Joined: 10 Jul 2008
Total Posts: 1700
24 Feb 2015 12:09 PM
All should work, apart from

--
player = game.Players:FindFirstChild()
--

Wtf? You need to provide a string for it to search for.
Report Abuse
FunkiAndrew is not online. FunkiAndrew
Joined: 01 Dec 2013
Total Posts: 2318
24 Feb 2015 12:12 PM
sly is right. I recommend :GetChildren() not :FindFirstChild()
Report Abuse
ReverseUniverse is not online. ReverseUniverse
Joined: 23 Jan 2015
Total Posts: 1118
24 Feb 2015 12:18 PM
I thought this would find the string

local StringValue = Instance.new("StringValue", player)
StringValue.Name = "Alive"
Report Abuse
ReverseUniverse is not online. ReverseUniverse
Joined: 23 Jan 2015
Total Posts: 1118
24 Feb 2015 12:20 PM
bump-2
Report Abuse
FunkiAndrew is not online. FunkiAndrew
Joined: 01 Dec 2013
Total Posts: 2318
24 Feb 2015 12:21 PM
local StringValue = Instance.new("StringValue", player)
StringValue.Name = "Alive"

Does NOT find the string, it MAKES the string...
your basically giving them 250 free points...
Report Abuse
SLY3 is not online. SLY3
Joined: 10 Jul 2008
Total Posts: 1700
24 Feb 2015 12:25 PM
game.Players:FindFirstChild() wont work, because it's searching for nothing (nil)

Change it to this:

--
player = game.Players:FindFirstChild'PlayerName'
--
Report Abuse
ReverseUniverse is not online. ReverseUniverse
Joined: 23 Jan 2015
Total Posts: 1118
24 Feb 2015 12:25 PM
so how would i find it?

and the script right now won't even give out points...
Report Abuse
ReverseUniverse is not online. ReverseUniverse
Joined: 23 Jan 2015
Total Posts: 1118
24 Feb 2015 12:29 PM
--What current script looks like:

player = game.Players:FindFirstChild'PlayerName'
local StringValue = Instance.new("StringValue", player)
StringValue.Name = "Alive"

if player:FindFirstChild("Alive") then
points = player.leaderstats.Points
points.Value = points.Value + 250
end

--By the way this is a noraml script not local script.

--Also there is a brick that already gives the player a string value on touch.

--I just wanted this script to find the string value in the Player and if found give the Player 250 + points
Report Abuse
ReverseUniverse is not online. ReverseUniverse
Joined: 23 Jan 2015
Total Posts: 1118
24 Feb 2015 12:30 PM
bump
Report Abuse
ReverseUniverse is not online. ReverseUniverse
Joined: 23 Jan 2015
Total Posts: 1118
24 Feb 2015 12:32 PM
bump-2
Report Abuse
Pkamara is not online. Pkamara
Joined: 25 Apr 2013
Total Posts: 95
24 Feb 2015 12:36 PM
What are you exactly asking and why are you naming the StringValue instance "Alive" when you can give it the value of Alive...
Report Abuse
SLY3 is not online. SLY3
Joined: 10 Jul 2008
Total Posts: 1700
24 Feb 2015 12:50 PM
Omfg

--
player = game.Players:FindFirstChild'PlayerName'
--

I meant put the player's name in the string it's searching for.
Report Abuse
ReverseUniverse is not online. ReverseUniverse
Joined: 23 Jan 2015
Total Posts: 1118
24 Feb 2015 01:08 PM
Please show me how to put it in so i don't get confused :L
Report Abuse
ReverseUniverse is not online. ReverseUniverse
Joined: 23 Jan 2015
Total Posts: 1118
24 Feb 2015 01:09 PM
And i'm not searching for one certain player i'm looking for the local player...
Report Abuse
ReverseUniverse is not online. ReverseUniverse
Joined: 23 Jan 2015
Total Posts: 1118
24 Feb 2015 01:10 PM
bump-3
Report Abuse
SLY3 is not online. SLY3
Joined: 10 Jul 2008
Total Posts: 1700
24 Feb 2015 01:10 PM
Do this:

local player = game.Players.LocalPlayer
Report Abuse
ReverseUniverse is not online. ReverseUniverse
Joined: 23 Jan 2015
Total Posts: 1118
24 Feb 2015 01:19 PM
Like this?

local player = game.Players.LocalPlayer
local StringValue = Instance.new("StringValue", player)
StringValue.Name = "Alive"

if player:FindFirstChild("Alive") then
points = player.leaderstats.Points
points.Value = points.Value + 250
end
Report Abuse
SLY3 is not online. SLY3
Joined: 10 Jul 2008
Total Posts: 1700
24 Feb 2015 01:44 PM
Yeah, but why are you re-checking for "Alive"?
Report Abuse
ReverseUniverse is not online. ReverseUniverse
Joined: 23 Jan 2015
Total Posts: 1118
24 Feb 2015 01:51 PM
Scritp still does not work...
Report Abuse
ReverseUniverse is not online. ReverseUniverse
Joined: 23 Jan 2015
Total Posts: 1118
24 Feb 2015 01:52 PM
*Script
Report Abuse
Rocky28447 is online. Rocky28447
Joined: 11 Dec 2009
Total Posts: 2912
24 Feb 2015 01:55 PM
That's because you didn't put it in a LocalScript you idiot.
Report Abuse
SLY3 is not online. SLY3
Joined: 10 Jul 2008
Total Posts: 1700
24 Feb 2015 01:57 PM
Okay, I'll do it for you, since you've tried for so long:

(local script):

--
local plr = game.Players.LocalPlayer
local ls = Instance.new('IntValue',plr)
ls.Name = 'leaderstats'
local pts,alive = Instance.new('NumberValue',ls),Instance.new('StringValue',plr)
pts.Name = 'Points'alive.Name = 'Alive'
if plr:FindFirstChild'Alive'then
pts.Value = pts.Value + 250;end
--
Report Abuse
ReverseUniverse is not online. ReverseUniverse
Joined: 23 Jan 2015
Total Posts: 1118
24 Feb 2015 02:03 PM
It has been in local script and it still won't 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