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: I need help scripting this.. Semi-Poisonous fruit tree...

Previous Thread :: Next Thread 
Caedus1x1x1x1 is not online. Caedus1x1x1x1
Joined: 22 Sep 2011
Total Posts: 258
08 Aug 2014 01:48 AM
So uhh... This scripts parent is a piece of fruit on a tree. Every piece of fruit in my tree model will have this script in it. It's scripting so that every time I place it into my place from my models the fruit colors are all different.
My script works great other than the fact that the black colored fruit is supposed to be poisonous. Would anybody care to help me with my script? :/

It would be very much appreciated! C:

The script:


n=math.random(0,4)
if n==1 then
script.Parent.BrickColor=BrickColor.new("Bright red")
elseif n==2 then
script.Parent.BrickColor=BrickColor.new("Bright blue")
elseif n==3 then
script.Parent.BrickColor=BrickColor.new("Bright yellow")
elseif n==4 then
script.Parent.BrickColor=BrickColor.new("Royal purple")
else
script.Parent.BrickColor=BrickColor.new("Really black")
end

script.Parent.Touched:connect(function(hit)
plr=game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
if script.Parent.BrickColor=="Really black" then
plr.leaderstats.Hunger.Value=0
while true do
hit.Parent.Humanoid.Health=hit.Parent.Humanoid.Health-12
wait(1)
end
else
plr.leaderstats.Hunger.Value=plr.leaderstats.Hunger.Value-10
script.Parent:Remove()
end
end
end)
Report Abuse
Caedus1x1x1x1 is not online. Caedus1x1x1x1
Joined: 22 Sep 2011
Total Posts: 258
08 Aug 2014 01:50 AM
Please excuse my grammar. "It's scripted so that*"
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
08 Aug 2014 01:56 AM
Does it set the hunger to 0?
Report Abuse
Caedus1x1x1x1 is not online. Caedus1x1x1x1
Joined: 22 Sep 2011
Total Posts: 258
08 Aug 2014 02:02 AM
The black fruit is supposed to set the hunger to 0 and slowly repeatedly damage the character. And now that I think about this. I should have it set the hunger to 100... Not 0... But that's irrelevant seeing as neither setting the number or killing the player works.
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
08 Aug 2014 02:04 AM
If so

Player = defineit

While Player.leaderstats.Hunger.Value <= 0 do
Player.Character.Humanoid.Health = Player.Character.Humanoid.Health - 1
wait(.5)
End
Report Abuse
Caedus1x1x1x1 is not online. Caedus1x1x1x1
Joined: 22 Sep 2011
Total Posts: 258
08 Aug 2014 03:02 AM
I do appreciate you trying to help me. Unfortunately I was out of my mind when I first wrote the earlier code...

I did figure it out though! C:

The correct code for the fruit:


n=math.random(0,4)
if n==1 then
script.Parent.BrickColor=BrickColor.new("Bright red")
elseif n==2 then
script.Parent.BrickColor=BrickColor.new("Bright blue")
elseif n==3 then
script.Parent.BrickColor=BrickColor.new("Bright yellow")
elseif n==4 then
script.Parent.BrickColor=BrickColor.new("Royal purple")
else
script.Parent.BrickColor=BrickColor.new("Really black")
end
script.Parent.Touched:connect(function(hit)
plr=game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
if n~=0 then
plr.leaderstats.Hunger.Value=plr.leaderstats.Hunger.Value-10
else
plr.leaderstats.Hunger.Value=100
while true do
script.Parent.Transparency=100
hit.Parent.Humanoid.Health=hit.Parent.Humanoid.Health-6
wait(2)
end
end
script.Parent:Remove()
end
end)
Report Abuse
Caedus1x1x1x1 is not online. Caedus1x1x1x1
Joined: 22 Sep 2011
Total Posts: 258
08 Aug 2014 03:04 AM
"It grows various fruits. Just be sure not to eat any fruit that's black..."
Report Abuse
Caedus1x1x1x1 is not online. Caedus1x1x1x1
Joined: 22 Sep 2011
Total Posts: 258
08 Aug 2014 03:06 AM
I might make purple fruit poisonous too. I also plan to make it regen after a few minutes. Scripting is hours of fun! :D
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