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: What's wrong here?

Previous Thread :: Next Thread 
FisherPenguin is not online. FisherPenguin
Joined: 14 Jun 2010
Total Posts: 1157
06 Apr 2012 08:56 PM
This script is supposed to make a flag lower if conditions are right. When I touch the brick, nothing happens. Also No Output.

f = script.Parent.Parent.Flag --The Flag
b = script.Parent --The "Base", or part you touch to make the flag lower

local hit = Base.Touched:wait() --Wait for the base to be touched
local character = hit.Parent --The character that touched the base
local player = game.Players:GetPlayerFromCharacter(character) --Player of the character that touched the base
local touch = b.Touched:connect(function() --When the base is touched
local nottouch = b.TouchEnded:connect(function() --When the base stops being touched

b.Touched:connect(function() --When the base is touched
if player:IsInGroup(225681) and f.BrickColor == ("Bright red") and touch == true and nottouch == false then --If the Player is in R.W., and the flags BrickColor is Bright red, and it is being touched, and it is not being nottouched
for i=1, 400 do --400 times do
wait(0.04) -- wait .4
f.Position = f.Position + Vector3.new(0, -0.1, 0) move the flag -.1
end -- end the for
f.BrickColor = BrickColor.new("Navy blue") --BrickColor changes to Navy blue
wait() --Wait for safety
else --Otherwise
end
end
end
end


+-Fishy
Report Abuse
FisherPenguin is not online. FisherPenguin
Joined: 14 Jun 2010
Total Posts: 1157
06 Apr 2012 09:37 PM
Bawmp. Come on, It has to be at least close. And I'm testing it in Play solo, but it should work in there, right?

+-Fishy
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
06 Apr 2012 10:07 PM
Man, you do NOT give up! Should I just give you my flag?
Report Abuse
dirk29 is not online. dirk29
Joined: 26 May 2010
Total Posts: 1142
06 Apr 2012 10:09 PM
That script is so inefficient.
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
06 Apr 2012 10:10 PM
"That script is so inefficient."

At least he's trying. Unlike YOU saying your deal with coding the WEBSITE!
Report Abuse
dirk29 is not online. dirk29
Joined: 26 May 2010
Total Posts: 1142
06 Apr 2012 10:12 PM
miz, I just got on spring break. My alien ware laptop got a Trojan. It cost me $500 and i just got it back yesterday. Give me some slack.
Report Abuse
FisherPenguin is not online. FisherPenguin
Joined: 14 Jun 2010
Total Posts: 1157
06 Apr 2012 10:21 PM
Whoah. Start a fight somewhere else :P. This is the closest I've got. And no, I don't generally give up miz :P You should know that by now. But do you see anything wrong? I have no idea why this wouldnt work :/

+-Fishy
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
06 Apr 2012 10:24 PM
You're saying this in your touched event

if touch == true

You can't say something like

function name(bla)
if name == true

return it.
Report Abuse
FisherPenguin is not online. FisherPenguin
Joined: 14 Jun 2010
Total Posts: 1157
06 Apr 2012 10:30 PM
So like this?

f = script.Parent.Parent.Flag --The Flag
b = script.Parent --The "Base", or part you touch to make the flag lower

local hit = Base.Touched:wait() --Wait for the base to be touched
local character = hit.Parent --The character that touched the base
local player = game.Players:GetPlayerFromCharacter(character) --Player of the character that touched the base
local touch = b.Touched:connect(function(hit) --When the base is touched
local nottouch = b.TouchEnded:connect(function(nothit) --When the base stops being touched

b.Touched:connect(function() --When the base is touched
if player:IsInGroup(225681) and f.BrickColor == ("Bright red") and hit == true and nothit == false then --[[If the Player is in R.W., and the flags BrickColor is Bright red, and it is being touched, and it is not being nottouched
for i=1, 400 do --400 times do
wait(0.04) -- wait .4
f.Position = f.Position + Vector3.new(0, -0.1, 0) move the flag -.1
end -- end the for
f.BrickColor = BrickColor.new("Navy blue") --BrickColor changes to Navy blue
wait() --Wait for safety
else --Otherwise
end
end
end
end
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
06 Apr 2012 10:39 PM
You don't really need to check if an event is running as of a fact you say

b.Touched:connect(function()
Report Abuse
FisherPenguin is not online. FisherPenguin
Joined: 14 Jun 2010
Total Posts: 1157
06 Apr 2012 10:42 PM
But at the same time I dont know how to check if a player is continuously touching a brick. So that's why I checked them, so if the player stops touching the brick, it will stop the flag from moving. I don't know any other way to do this :/

+-Fishy
Report Abuse
GoldenUrg is not online. GoldenUrg
Joined: 23 Aug 2009
Total Posts: 6428
06 Apr 2012 10:54 PM
What exactly are the conditions you are trying to check for?
Report Abuse
FisherPenguin is not online. FisherPenguin
Joined: 14 Jun 2010
Total Posts: 1157
06 Apr 2012 10:55 PM
Let me re-word that. The reason I'm checking is because I know no other way to check when a player stops touching a brick, and then stop the flag from moving.

+-Fishy
Report Abuse
GoldenUrg is not online. GoldenUrg
Joined: 23 Aug 2009
Total Posts: 6428
06 Apr 2012 11:09 PM
How about?

f = script.Parent.Parent.Flag --The Flag
b = script.Parent --The "Base", or part you touch to make the flag lower

local istouching = false

function lowerflag()
for i=1, 400 do --400 times do
wait(0.04) -- wait .4
f.Position = f.Position + Vector3.new(0, -0.1, 0) move the flag -.1
if not istouching then break end -- may want to reset the flag or otherwise make this not restart
end -- end the for
f.BrickColor = BrickColor.new("Navy blue") --BrickColor changes to Navy blue
end

b.Touched:connect(function( hit ) --When the base is touched
local character = hit.Parent --The character that touched the base
local player = game.Players:GetPlayerFromCharacter(character) --Player of the character that touched the base

if( istouching ) then return end

if player:IsInGroup(225681) and f.BrickColor == ("Bright red") then --If the Player is in R.W., and the flags BrickColor is Bright red
istouching = true
Spawn(lowerflag)
end
end)

b.TouchEnded:connect(function( hit ) --When the base is not touched
istouching = false
end )
Report Abuse
FisherPenguin is not online. FisherPenguin
Joined: 14 Jun 2010
Total Posts: 1157
06 Apr 2012 11:29 PM
Nope, yours didn't work either :/

+-Fishy
Report Abuse
GoldenUrg is not online. GoldenUrg
Joined: 23 Aug 2009
Total Posts: 6428
06 Apr 2012 11:38 PM
Define "didn't work". I didn't try it so it probably doesn't compile.
Report Abuse
FisherPenguin is not online. FisherPenguin
Joined: 14 Jun 2010
Total Posts: 1157
06 Apr 2012 11:40 PM
"Didn't work" as in No Output, no flag movement.
I'm going to work on this more tomorrow, for a few reasons. #DoneForTonight.

+-Fishy
Report Abuse
GoldenUrg is not online. GoldenUrg
Joined: 23 Aug 2009
Total Posts: 6428
06 Apr 2012 11:45 PM
I'd suggest reading up on
http://wiki.roblox.com/index.php/Debugging
if you don't already know.

Find out what Touched and TouchEnded events are being triggered. Probably the TouchEnded is being triggered by some part while another is still touching.

Report Abuse
FisherPenguin is not online. FisherPenguin
Joined: 14 Jun 2010
Total Posts: 1157
07 Apr 2012 05:17 PM
Bump.

+-Fishy
Report Abuse
FisherPenguin is not online. FisherPenguin
Joined: 14 Jun 2010
Total Posts: 1157
07 Apr 2012 06:43 PM
Bawmperz.

+-Fishy
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
07 Apr 2012 07:13 PM
Think I fixed the script

Want me to post it or point out whats wrong in your script?
Report Abuse
FisherPenguin is not online. FisherPenguin
Joined: 14 Jun 2010
Total Posts: 1157
07 Apr 2012 07:58 PM
Post it and point it out. I like to actually learn how to do this kinda stuff, not just have it all gave to me :P

+-Fishy
Report Abuse
FisherPenguin is not online. FisherPenguin
Joined: 14 Jun 2010
Total Posts: 1157
07 Apr 2012 08:51 PM
Bump.

+-Fishy
Report Abuse
FisherPenguin is not online. FisherPenguin
Joined: 14 Jun 2010
Total Posts: 1157
08 Apr 2012 09:06 PM
Give me a B, give me an A, give me a W, give me a M, give me a P! What does that spell?!? BAWMP!

+-Fishy
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