|
| 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 |
|
|
|
| 08 Aug 2014 01:50 AM |
| Please excuse my grammar. "It's scripted so that*" |
|
|
| Report Abuse |
|
|
|
| 08 Aug 2014 01:56 AM |
| Does it set the hunger to 0? |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 08 Aug 2014 03:04 AM |
| "It grows various fruits. Just be sure not to eat any fruit that's black..." |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|