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: Why doesn't this LocalScript work?

Previous Thread :: Next Thread 
thetacah is not online. thetacah
Joined: 18 Jan 2013
Total Posts: 16026
09 Feb 2014 10:10 AM
local player = game.Players.LocalPlayer

player.GunInt.Value.Changed:connect(function()
game.StarterGui.ScreenGui.Text1.Text = player.GunInt.Value


end)



It's for ammo, I need it to change the text to the ammount of ammo. I have an int and a gun script that you can see here:http://www.roblox.com/Forum/ShowPost.aspx?PostID=125260655
Report Abuse
dodleman is not online. dodleman
Joined: 22 Dec 2007
Total Posts: 1118
09 Feb 2014 10:14 AM
Why are you changing the gui in StaterGui? Change the one in the Player's PlayerGui...

Life is potatoes to me
Report Abuse
thetacah is not online. thetacah
Joined: 18 Jan 2013
Total Posts: 16026
09 Feb 2014 10:17 AM
idk, but this still doesn't work.


local player = game.Players.LocalPlayer

player.GunInt.Value.Changed:connect(function()
player.PlayerGui.ScreenGui.Text1.Text = player.GunInt.Value


end)
Report Abuse
Kingmouli is not online. Kingmouli
Joined: 28 Sep 2012
Total Posts: 1292
09 Feb 2014 10:17 AM
Change works on Instances not on properties
Report Abuse
VoltiCoil is not online. VoltiCoil
Joined: 20 Nov 2008
Total Posts: 1227
09 Feb 2014 10:17 AM
local player = game.Players.LocalPlayer

player.GunInt.Value.Changed:connect(function()
game.PlayerGui.ScreenGui.Text1.Text = player.GunInt.Value

end)
Report Abuse
WebGL3D is online. WebGL3D
Joined: 04 Sep 2013
Total Posts: 28311
09 Feb 2014 10:17 AM
All LocalScripts need wait, and properties don't have Changed events

wait()
local player = game.Players.LocalPlayer
player.GunInt.Changed:connect(function(v)
player.PlayerGui.ScreenGui.Text1.Text = v
end)


~ 1Topcop ~ Java3D ~ WebGL3D ~ Hoard3D ~ Thug3D
Report Abuse
VoltiCoil is not online. VoltiCoil
Joined: 20 Nov 2008
Total Posts: 1227
09 Feb 2014 10:18 AM
oops

local player = game.Players.LocalPlayer

player.GunInt.Value.Changed:connect(function()
game.Players.player.PlayerGui.ScreenGui.Text1.Text = player.GunInt.Value

end)
Report Abuse
dodleman is not online. dodleman
Joined: 22 Dec 2007
Total Posts: 1118
09 Feb 2014 10:18 AM
You
can
not
use
.Changed
on
a
property

Life is potatoes to me
Report Abuse
thetacah is not online. thetacah
Joined: 18 Jan 2013
Total Posts: 16026
09 Feb 2014 10:19 AM
How would I make it when the value of my int changes then?
Report Abuse
WebGL3D is online. WebGL3D
Joined: 04 Sep 2013
Total Posts: 28311
09 Feb 2014 10:20 AM
Or try and use a variable in a path using the dot separators :p
player = "name"
game.Players[player] -- Correct
game.Players.player -- Wrong

But since 'player' is an object in this scenario already pointing to the player, you just use 'player'


~ 1Topcop ~ Java3D ~ WebGL3D ~ Hoard3D ~ Thug3D
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
09 Feb 2014 10:20 AM
wait(0.2)
local Player = game.Players.LocalPlayer

player.GunInt.Value.Changed:connect(function()
game.Players[Player].PlayerGui.ScreenGui.Text1.Text = Player.GunInt.Value

end)
Report Abuse
WebGL3D is online. WebGL3D
Joined: 04 Sep 2013
Total Posts: 28311
09 Feb 2014 10:20 AM
@Thet did you read my first reply?


~ 1Topcop ~ Java3D ~ WebGL3D ~ Hoard3D ~ Thug3D
Report Abuse
VoltiCoil is not online. VoltiCoil
Joined: 20 Nov 2008
Total Posts: 1227
09 Feb 2014 10:20 AM
I gotta learn to read before I post...

Here:

local player = game.Players.LocalPlayer

player.GunInt.Changed:connect(function()
game.Players.player.PlayerGui.ScreenGui.Text1.Text = player.GunInt.Value

end)
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
09 Feb 2014 10:21 AM
I fixed basically what WebGL said.
Report Abuse
WebGL3D is online. WebGL3D
Joined: 04 Sep 2013
Total Posts: 28311
09 Feb 2014 10:21 AM
@lord do not try to help if you don't know how ._.


~ 1Topcop ~ Java3D ~ WebGL3D ~ Hoard3D ~ Thug3D
Report Abuse
WebGL3D is online. WebGL3D
Joined: 04 Sep 2013
Total Posts: 28311
09 Feb 2014 10:22 AM
@lord,Volt neither of your "fixes" will work. ._.


~ 1Topcop ~ Java3D ~ WebGL3D ~ Hoard3D ~ Thug3D
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
09 Feb 2014 10:23 AM
What do you mean? I stated that I made the fix that you talked about in the post above me.

And this is the correct code:
wait(0.2)
local Player = game.Players.LocalPlayer
Player.GunInt.Changed:connect(function()
game.Players[Player].PlayerGui.ScreenGui.Text1.Text = tostring(Player.GunInt.Value)
end)
Report Abuse
Kingmouli is not online. Kingmouli
Joined: 28 Sep 2012
Total Posts: 1292
09 Feb 2014 10:23 AM
plyr = game.Players.LocalPlayer

plyr.YOURINT.Changed:connect(function()
plyr.PlayerGui.SCREENGUI.TEXTTHINGGY.Text = plyr.YOURINT.Value
end)
Report Abuse
WebGL3D is online. WebGL3D
Joined: 04 Sep 2013
Total Posts: 28311
09 Feb 2014 10:24 AM
But since 'player' is an object in this scenario already pointing to the player, you just use 'player'

game.Players[Player] would error, you can't use an object in a path, and Player is already an object, so you could just use Player rather than make a new path.
And when you use the Changed event on a Value object, it passes the new value

Value.Changed:connect(function(newValue)


~ 1Topcop ~ Java3D ~ WebGL3D ~ Hoard3D ~ Thug3D
Report Abuse
Kingmouli is not online. Kingmouli
Joined: 28 Sep 2012
Total Posts: 1292
09 Feb 2014 10:24 AM
Guys stop posting scripts with errors a beginner wouldn't make...
Report Abuse
WebGL3D is online. WebGL3D
Joined: 04 Sep 2013
Total Posts: 28311
09 Feb 2014 10:25 AM
@King I'm not seeing any errors here,


wait()
local player = game.Players.LocalPlayer
player.GunInt.Changed:connect(function(v)
player.PlayerGui.ScreenGui.Text1.Text = v
end)


~ 1Topcop ~ Java3D ~ WebGL3D ~ Hoard3D ~ Thug3D
Report Abuse
Kingmouli is not online. Kingmouli
Joined: 28 Sep 2012
Total Posts: 1292
09 Feb 2014 10:26 AM
Soz, I keep getting ninja-ed, and I thought Changed passes the Property that changed?
Report Abuse
WebGL3D is online. WebGL3D
Joined: 04 Sep 2013
Total Posts: 28311
09 Feb 2014 10:28 AM
Changed passes the property changed for almost every object, Value objects are not one of those.


~ 1Topcop ~ Java3D ~ WebGL3D ~ Hoard3D ~ Thug3D
Report Abuse
thetacah is not online. thetacah
Joined: 18 Jan 2013
Total Posts: 16026
09 Feb 2014 10:29 AM
Guys, I fixed it. thx to the guys who said wait and to put it to the Intvalue, not the value.
Report Abuse
WebGL3D is online. WebGL3D
Joined: 04 Sep 2013
Total Posts: 28311
09 Feb 2014 10:29 AM
You're welcome ;p


~ 1Topcop ~ Java3D ~ WebGL3D ~ Hoard3D ~ Thug3D
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