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: Why doesn't this work? (It's a flag)

Previous Thread :: Next Thread 
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
22 Sep 2013 08:19 PM
It's creepy. NO error messages whatsoever

local flag = script.Parent
local base = script.Parent.Parent.Base

function OnTouch (base)
local humanoid = hit.Parent:findFirstChild("Humanoid")
if (hit.Parent:findFirstChild("Humanoid")~= nil) then return end
if (game.Players:playerFromCharacter(hit.Parent)~= nil) then
local thief = game.Players:playerFromCharacter(hit.Parent)
flag.BrickColor = thief.TeamColor
end
end

while flag.BrickColor == BrickColor.new ('Deep orange') do
game.Teams['Dauntless Empire'].Score = 1
wait (1)
game.Teams['Dauntless Empire'].Score = 1
end

while flag.BrickColor == BrickColor.new ('Really red') do
game.Teams['Raiders'].Score = 1
wait (1)
end

I even tried print statements in every one, and none of them print!
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
22 Sep 2013 08:31 PM
local flag = script.Parent
local base = script.Parent.Parent.Base

function OnTouch (base)
local humanoid = hit.Parent:findFirstChild("Humanoid")
if (hit.Parent:findFirstChild("Humanoid")~= nil) then return end
if (game.Players:playerFromCharacter(hit.Parent)~= nil) then
local thief = game.Players:playerFromCharacter(hit.Parent)
flag.BrickColor = thief.TeamColor
end
end

flag.Touched:connect(OnTouch)

while flag.BrickColor == BrickColor.new ('Deep orange') do
game.Teams['Dauntless Empire'].Score = 1
wait (1)
game.Teams['Dauntless Empire'].Score = 1
end

while flag.BrickColor == BrickColor.new ('Really red') do
game.Teams['Raiders'].Score = 1
wait (1)
end
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
23 Sep 2013 04:37 PM
I feel like an idiot. Rookie mistake to forget a connection line. Thanks!
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
25 Sep 2013 06:58 AM
Added it, but now it doesn't know what hit is.

Why can I never properly defined hit?
Report Abuse
LuaWeaver is not online. LuaWeaver
Joined: 28 Jun 2013
Total Posts: 213
25 Sep 2013 07:02 AM
You have:
function OnTouch(base)
...

"hit", as you refer to, is really just the parameter. Right now it's base. Try changing it to:

function onTouch(hit)
...
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
26 Sep 2013 06:43 AM
Well, that at least gave me a "Touch Interest" object in the Base, so we're getting somewhere, but still NO error lines:

local flag = script.Parent.Parent.Flag
local base = script.Parent

function OnTouch (hit)
local humanoid = hit.Parent:findFirstChild("Humanoid")
if (hit.Parent:findFirstChild("Humanoid")~= nil) then return end
if (game.Players:playerFromCharacter(hit.Parent)~= nil) then
print 'Test1'
local thief = game.Players:playerFromCharacter(hit.Parent)
flag.BrickColor = thief.TeamColor
end
end

flag.Touched:connect (OnTouch)

local flag = script.Parent.Parent.Flag
local base = script.Parent

while flag.BrickColor == BrickColor.new ('Deep orange') do
print 'DE has flag!'
game.Teams['Dauntless Empire'].Score = game.Teams['Dauntless Empire'].Score + 1
wait (1)
end

local flag = script.Parent.Parent.Flag
local base = script.Parent

while flag.BrickColor == BrickColor.new ('Really red') do
print 'Raiders!'
game.Teams['Raiders'].Score = game.Teams['Raiders'].Score + 1
wait (1)
end

Do I have to make this a local script, and link the source to the base?
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
30 Sep 2013 06:35 AM
Sorry. Bump!
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
30 Sep 2013 09:40 AM
2 while loops.
Obviously it's going to wait till the first one is done
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
03 Oct 2013 06:47 AM
Nice! But I'm having trouble with the first Hit function. I'll modify it and separate the while loops.
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
03 Oct 2013 07:11 AM
This is the only part NOT working for me (I fixed everything else)

local flag = script.Parent.Parent.Flag
local base = script.Parent

function OnTouch (hit)
local humanoid = hit.Parent:findFirstChild("Humanoid")
if (hit.Parent:findFirstChild("Humanoid")~= nil) then return end
if (game.Players:playerFromCharacter(hit.Parent)~= nil) then
print 'Test1'
local thief = game.Players:playerFromCharacter(hit.Parent)
flag.BrickColor = thief.TeamColor
end
end

local flag = script.Parent.Parent.Flag
flag.Touched:connect (OnTouch)

I have a feeling my connection line is wrong
Report Abuse
DragonODeath is not online. DragonODeath
Joined: 02 May 2011
Total Posts: 1252
03 Oct 2013 07:13 AM
LIne 8

print 'Test'
I do not see your parentheses.
Report Abuse
sam8985 is not online. sam8985
Joined: 12 Nov 2011
Total Posts: 582
03 Oct 2013 07:55 AM
You don't need parentheses when printing plain text.
Report Abuse
Project2015 is not online. Project2015
Joined: 11 Sep 2013
Total Posts: 384
03 Oct 2013 08:04 AM
print 'Test'
print "Test"
print ('Test')
print("Test")

All of these will work.
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
03 Oct 2013 06:38 PM
Great. Knew that. Now that we've established that, can we move on?
What is actually wrong? (Thanks for trying, Dragon)
Report Abuse
ProjectsHidden is not online. ProjectsHidden
Joined: 29 Sep 2013
Total Posts: 194
03 Oct 2013 07:17 PM
flag = script.Parent
base = script.Parent.Parent.Base
defendteam = ["Defenders"]
raid = ["Raiders"]
--DONT TOUCH BELOW--
t = game:GetService("Teams")
plrs = game:GetService("Players")

currentowner = defendteam

function update()
flag.BrickColor = t[currentowner].TeamColor
end

function isonteam(plr, team)
return plr.TeamColor == t[team].TeamColor
end

base.Touched:connect(function(hit)
local h = hit.Parent:FindFirstChild("Humanoid")
if not h then return end
if h.Health < 1 then return end
local char = hit.Parent
if char == workspace then return end
local plr = plrs:GetPlayerFromCharacter(char)
if not plr then return end
if isonteam(plr, currentowner) then return end
if isonteam(plr, raid) then
currentowner = raid
update()
elseif isonteam(plr, defendteam) then
currentowner = defendteam
update()
end
end)

Spawn(function()
while flag.BrickColor.Name == t[defendteam].TeamColor do
t[defendteam].Score = 1
wait(1)
t[defendteam].Score = 1
end
end)
Spawn(function()
while flag.BrickColor.Name == t[raid].TeamColor do
t[raid].Score = 1
wait(1)
t[raid].Score = 1
end
end)
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
03 Oct 2013 07:38 PM
Wholly shiz...
Didn't realize it was that complicated. I'll try it.
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