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

Previous Thread :: Next Thread 
JellyJ3eans is not online. JellyJ3eans
Joined: 10 May 2011
Total Posts: 486
20 Aug 2016 04:24 PM
Trying to make a seat give you a leaderstat depending on how long you sit in it

I tried a while true do loop which didn't work and I scrapped that,
But now I'm trying a for loop. Here's the code :

function onTouched(hit)
local h = hit.Parent:findFirstChild("Humanoid")
if h and h.Sit == true then
for _, player in ipairs(game.Players:GetPlayers()) do
if player:FindFirstChild("leaderstats") then
player.leaderstats.Intelligence.Value = player.leaderstats.Intelligence.Value - 1
end
end
end
end



Report Abuse
JellyJ3eans is not online. JellyJ3eans
Joined: 10 May 2011
Total Posts: 486
20 Aug 2016 04:24 PM
Also, how do you make a leaderstat unable to go over a certain number..?
Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
20 Aug 2016 04:27 PM
you can use an intconstrainedvalue to make a leaderstat unable to go over a certain number

http://wiki.roblox.com/index.php?title=API:Class/IntConstrainedValue
Report Abuse
JellyJ3eans is not online. JellyJ3eans
Joined: 10 May 2011
Total Posts: 486
20 Aug 2016 04:32 PM
Dude, that's perfect, thanks! I never knew what IntConstrainedValue's did
Report Abuse
JellyJ3eans is not online. JellyJ3eans
Joined: 10 May 2011
Total Posts: 486
20 Aug 2016 04:34 PM
but bump for main topic
Report Abuse
JellyJ3eans is not online. JellyJ3eans
Joined: 10 May 2011
Total Posts: 486
20 Aug 2016 04:39 PM
Bump
Report Abuse
JellyJ3eans is not online. JellyJ3eans
Joined: 10 May 2011
Total Posts: 486
20 Aug 2016 05:03 PM
Bumpity bump bmp
Report Abuse
JellyJ3eans is not online. JellyJ3eans
Joined: 10 May 2011
Total Posts: 486
20 Aug 2016 05:14 PM
boomp
Report Abuse
JellyJ3eans is not online. JellyJ3eans
Joined: 10 May 2011
Total Posts: 486
20 Aug 2016 05:26 PM
last boomp then thread die :(
Report Abuse
Wowgnomes is not online. Wowgnomes
Joined: 27 Sep 2009
Total Posts: 26255
20 Aug 2016 05:28 PM
function onTouched(hit)
local h = hit.Parent:findFirstChild("Humanoid")
while h and h.Sit == true do
if game.Players[Humanoid.Parent.Name].leaderstats then
game.Players[Humanoid.Parent.Name].leaderstats.Intelligence.Value = game.Players[Humanoid.Parent.Name].leaderstats.Intelligence.Value - 1
wait(1) -- seconds it takes to subtract one intellegence
end
end
end

try that :)
Report Abuse
JellyJ3eans is not online. JellyJ3eans
Joined: 10 May 2011
Total Posts: 486
20 Aug 2016 05:30 PM
i'll see how this does
Report Abuse
JellyJ3eans is not online. JellyJ3eans
Joined: 10 May 2011
Total Posts: 486
20 Aug 2016 05:36 PM
Says unknown global humanoid under the

if game.Players[Humanoid.Parent.Name].leaderstats then

part

Also I made a local variable for finding the humanoid already
Won't local variables work in an if-then statement..?

Sorry for my newbieness I'm new to this
Report Abuse
Wowgnomes is not online. Wowgnomes
Joined: 27 Sep 2009
Total Posts: 26255
20 Aug 2016 05:37 PM
yeah sorry i wasn't really paying attention, just change Humanoid to h in all appearances
Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
20 Aug 2016 05:38 PM
h.Parent.Name
Report Abuse
Wowgnomes is not online. Wowgnomes
Joined: 27 Sep 2009
Total Posts: 26255
20 Aug 2016 05:42 PM
08-20-2016 03:28 PM
function onTouched(hit)
local h = hit.Parent:findFirstChild("Humanoid")
while h and h.Sit == true do
if game.Players[h.Parent.Name].leaderstats then
game.Players[h.Parent.Name].leaderstats.Intelligence.Value = game.Players[h.Parent.Name].leaderstats.Intelligence.Value - 1
wait(1) -- seconds it takes to subtract one intellegence
end
end
end

try that :)
Report Abuse
JellyJ3eans is not online. JellyJ3eans
Joined: 10 May 2011
Total Posts: 486
20 Aug 2016 05:51 PM
yah I changed Humanoid to h whenever I saw it in the script it still doesn't work
Report Abuse
JellyJ3eans is not online. JellyJ3eans
Joined: 10 May 2011
Total Posts: 486
20 Aug 2016 06:24 PM
noooo they went offline halp
Report Abuse
Wowgnomes is not online. Wowgnomes
Joined: 27 Sep 2009
Total Posts: 26255
20 Aug 2016 06:28 PM
what does it print
if it doesn't print anything check if it is actually a leaderstat
Report Abuse
JellyJ3eans is not online. JellyJ3eans
Joined: 10 May 2011
Total Posts: 486
20 Aug 2016 06:30 PM
It doesn't print anything idk

The Value is changed to IntConstrainedValue just like how @aggressivecatch recommended to me
Report Abuse
JellyJ3eans is not online. JellyJ3eans
Joined: 10 May 2011
Total Posts: 486
20 Aug 2016 06:38 PM
ughhhh i feel like this is so simple but i'm so dumb for not knowing how to do this
Report Abuse
JellyJ3eans is not online. JellyJ3eans
Joined: 10 May 2011
Total Posts: 486
20 Aug 2016 08:46 PM
@Wowgnomes

Nevermind no more help needed,

it was because I didn't call the function on touch
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