of     2   
chevron_rightchevron_rightchevron_right

DarkStrike3
#63506418Sunday, February 26, 2012 11:12 PM GMT

Im making a Warrior cats game, in the book the cats starve if they don't eat, so im trying to make a script where every 5 seconds, the player takes a 5 damage Local timewait = 5 function wait(timewait) While true do game.workspace.players damage.Players > 5 end end I really don't know if thats right, Please help me Oh and before anyone says my script is horrible and stuff, iv'e tried learning to script, i study codes every day, its just VERY hard for me, so please, if your not going to help me out, don't post dumb little things like i suck at scripting, cause thats not useful
LightedRoblox
#63506579Sunday, February 26, 2012 11:15 PM GMT

It's not ">". It's "-".
LightedRoblox
#63506615Sunday, February 26, 2012 11:15 PM GMT

And your script is completely messed up.
aboy5643
#63506637Sunday, February 26, 2012 11:16 PM GMT

local timewait = 5 -- watch your caps on keywords like local function name() -- You need to name functions and put "()" after them wait(timewait) -- Good while true do -- Capitalization on while for i, v in pairs(game.Players:GetChildren()) do -- loop through every player v.Character.Humanoid.Health = v.Character.Humanoid.Health - 5 --Make the humanoid lose 5 health end -- end the for end -- end the while end -- end the function name() -- call the function
miz656
#63506658Sunday, February 26, 2012 11:16 PM GMT

What's your functions name and where are the parameters of it?
DarkStrike3
#63506773Sunday, February 26, 2012 11:18 PM GMT

I know my script is messed up, I just can't remember everything that comes in to scripting, and Lua is the easy one?! lol Also that script, does it loop through every player then end, or does it damage them, wait so long, then keep damaging them?
LUExtremePowerDragon
#63506819Sunday, February 26, 2012 11:19 PM GMT

I think "While true do" should be "while true do"
DarkStrike3
#63506828Sunday, February 26, 2012 11:19 PM GMT

and miz, i really have no clue what you mean, sorry
aboy5643
#63506830Sunday, February 26, 2012 11:19 PM GMT

My script damages EVERY player for 5 health every 5 seconds and will continue that forever.
DarkStrike3
#63506943Sunday, February 26, 2012 11:21 PM GMT

The ONLY thing i know in scripting is the wait, but i yet to learn where i can use that lol i have ideas for scripts, i just don't have the brain to make them work.... YET
DarkStrike3
#63506989Sunday, February 26, 2012 11:21 PM GMT

And ok, thank you aboy
stravant
Forum Moderator
#63507010Sunday, February 26, 2012 11:22 PM GMT

"in the book the cats starve if they don't eat" I think that that's more of a universal property of life that a property of the book =P Anyways, the code you posted look like you just randomly wrote some bits you saw in other scripts down. Unfortunately scripting is like math, you have to be very precise for stuff to work, so you'll never get anything to work if you try to code it like that, you'll have to look up some explanations of how things generally work to have some starting point. Heres a fixed version: local WaitTime = 10 --5 is a bit short, don't you think? local Damage = 5 while true do wait(WaitTime) for _, p in pairs(game.Players:GetChildren()) do p.Character.Humanoid:TakeDamage(Damage) end end
aboy5643
#63507057Sunday, February 26, 2012 11:23 PM GMT

For being able to admit that and know that, you will end up learning scripting with no problem. That's a lot of people's issue is that they get ahead of what their brain will let them do and get frustrated, ultimately ending up in failure. Realizing you can't do everything yet is a promising sign of a budding scripter.
miz656
#63507133Sunday, February 26, 2012 11:24 PM GMT

Yeah, I would use stravant's code. It waits 10 seconds. It takes about 6 or 7 seconds for the player to respawn, making aboys script maybe to error.
DarkStrike3
#63507215Sunday, February 26, 2012 11:25 PM GMT

Lol yes i guess stravant, Ok, and yes and no, some stuff is i looked in others scripts, to see how its done, A lot of codes to me just looks like random stuff someone wrote, thats a reason why its hard. Ill try both scripts, and tell you which is better, they both seem very good though and yes 5 is a bit short i guess
aboy5643
#63507267Sunday, February 26, 2012 11:26 PM GMT

@miz That wouldn't affect anything. Stravant's and I's do the same thing. Only he removed the function() and left the index of the for loop anonymous which makes sense honestly :P and he tweaked the values to his liking lol. My code was perfectly valid and does the same thing.
kingkiller1000
#63507298Sunday, February 26, 2012 11:26 PM GMT

ABoys would be fine if you made sure that the character existed. The worry is more that if you don't eat in 20 seconds, you die.
miz656
#63507336Sunday, February 26, 2012 11:27 PM GMT

There's really not a whole change except the waits and aboy subtraced while stravant used TakeDamage method.
DarkStrike3
#63507385Sunday, February 26, 2012 11:28 PM GMT

And ok, thank you for all the help I really wanna learn how to write my own scripts, cause when im older i always wanted to design games, most times i try writing my own, HOPING to get a working one, so far though i haven't got a working one, but hey, i have plenty of time to learn, so one day ill learn how to script like pros lol but even the best need help once and a while.
miz656
#63507399Sunday, February 26, 2012 11:28 PM GMT

"The worry is more that if you don't eat in 20 seconds, you die." As of a fact you're dressed up like a chicken, maybe I should eat you...That'll give me 3 months worth of dinner ;D
DarkStrike3
#63507541Sunday, February 26, 2012 11:30 PM GMT

Lol thanks for all the help guys, i really couldn't have done it without help
miz656
#63507590Sunday, February 26, 2012 11:31 PM GMT

You're kinda welcome.
DarkStrike3
#63507827Sunday, February 26, 2012 11:34 PM GMT

Ok the script works, but i did just found out why i made the time 5 lol unless i remove the helth regen, and idk how to do that nor do i think its possible, Well by the time the script goes back to 10, the player has full health again, so if i shorten the time, the script will be able to do damage faster then a player can gain health back, BUT im thinking, should i lower the damage and leave the time/make it higher, or should i lower the time? how would i do this
DarkStrike3
#63507964Sunday, February 26, 2012 11:37 PM GMT

Ok wait, i just thought of something thats very important, whats a players health? like before he takes ANY damage or anything, i heard its 100
aboy5643
#63508155Sunday, February 26, 2012 11:39 PM GMT

It is 100. Players regain health at 1 per second. Just take this into account with how much damage to give per second yourself.

    of     2   
chevron_rightchevron_rightchevron_right