Tidbit1
|
  |
| Joined: 15 Jun 2009 |
| Total Posts: 92 |
|
|
| 21 Jun 2013 09:26 AM |
So here's the basics: There's a block called "Light". This block is touched by opposing teams. whose colors are Bright red and Bright Blue. Light starts off as Medium Stone Grey. As a team touches light, light is supposed to change to that color. Now, for each color that light becomes, a block called "Head" changes position (it's a teleporter, if you need to know). I've written this myself, and I think I'm pretty close, but Light does not change color and output says nothing, no red underlines in the script, nothing. So here it is:
function touched(hit) if game.Players:GetPlayerFromCharacter(hit.Parent) == nil then return end
script.Parent.BrickColor = game.Players:GetPlayerFromCharacter(hit.Parent).TeamColor
if game.Workspace.TheCanopy.Light.BrickColor == BrickColor.new("Medium stone grey") then game.Workspace.TheCanopy.Head.Vector3.new(182.5, 282.4, 1290) end if game.Workspace.TheCanopy.Light.BrickColor == ("Medium stone grey") == false then end
if game.Workspace.TheCanopy.Light.BrickColor == BrickColor.new("Bright Blue") then game.Workspace.TheCanopy.Head.Vector3.new(188.5, 262, -129) end if game.Workspace.TheCanopy.Light.BrickColor == ("Bright Blue") == false then end
if game.Workspace.TheCanopy.Light.BrickColor == BrickColor.new("Bright Red") then game.Workspace.TheCanopy.Head.Vector3.new(179.5, 262, -129) end if game.Workspace.TheCanopy.Light.BrickColor == ("Bright Blue") == false then end
script.Parent.Touched:connect(touched)
print ("CP Accepted")
end
Please help me with this - I've been constantly working on it to no avail. If you need any more information, just say so! |
|
|
| Report Abuse |
|
|
Azarth
|
  |
| Joined: 17 Aug 2012 |
| Total Posts: 2760 |
|
|
| 21 Jun 2013 09:32 AM |
You had a a lot of errors, post back if you get any in the output now.
local brick = script.Parent local db = true function touched(hit) if hit and hit.Parent:findFirstChild("Humanoid") and db then db = false p = game.Players:GetPlayerFromCharacter(hit.Parent). brick.BrickColor = BrickColor.new(tostring(p.TeamColor)) if game.Workspace.TheCanopy.Light.BrickColor == BrickColor.new("Medium stone grey") then game.Workspace.TheCanopy.Head.Position = Vector3.new(182.5, 282.4, 1290) end if game.Workspace.TheCanopy.Light.BrickColor == BrickColor.new("Bright Blue") then game.Workspace.TheCanopy.Head.Position = Vector3.new(188.5, 262, -129) end if game.Workspace.TheCanopy.Light.BrickColor == BrickColor.new("Bright Red") then game.Workspace.TheCanopy.Head.Position = Vector3.new(179.5, 262, -129) end print ("CP Accepted") wait() db = true end end
brick.Touched:connect(touched)
|
|
|
| Report Abuse |
|
|
compy111
|
  |
| Joined: 02 Apr 2009 |
| Total Posts: 583 |
|
|
| 21 Jun 2013 09:38 AM |
I found this on the wiki:
function onTouched(otherPart) print(otherPart.Parent.Torso.BrickColor) -- Outputs the name of the color if otherPart.Parent.Torso.BrickColor == "Bright red" then -- This will not match print("Never gets executed") elseif otherPart.Parent.Torso.BrickColor.Name == "Bright red" then -- This will match print("Match occurred") end end
Never seen BrickColor.Name but if the wiki says it it might work.
Source: http://wiki.roblox.com/index.php/BrickColor_(Property) |
|
|
| Report Abuse |
|
|
Tidbit1
|
  |
| Joined: 15 Jun 2009 |
| Total Posts: 92 |
|
|
| 21 Jun 2013 09:40 AM |
As soon as I touched light, output said the following: 10:38:44.019 - Brick is not a valid member of Player 10:38:44.022 - Script "Workspace.TheCanopy.Light.Position Change", Line 7 10:38:44.023 - stack end 10:38:44.027 - Disconnected event because of exception
Thanks for all the help thus far! |
|
|
| Report Abuse |
|
|
Azarth
|
  |
| Joined: 17 Aug 2012 |
| Total Posts: 2760 |
|
|
| 21 Jun 2013 09:44 AM |
Did you remove the dot I accidentally put after (hit.Parent). <-- dot ? |
|
|
| Report Abuse |
|
|
Tidbit1
|
  |
| Joined: 15 Jun 2009 |
| Total Posts: 92 |
|
|
| 21 Jun 2013 09:45 AM |
Nope, I'll try that. I'll post back.
|
|
|
| Report Abuse |
|
|
Tidbit1
|
  |
| Joined: 15 Jun 2009 |
| Total Posts: 92 |
|
|
| 21 Jun 2013 09:46 AM |
| On this line "brick.BrickColor == BrickColor.new(tostring(p.TeamColor))" the red underlining says "'=' expected near '=='" |
|
|
| Report Abuse |
|
|
Azarth
|
  |
| Joined: 17 Aug 2012 |
| Total Posts: 2760 |
|
|
| 21 Jun 2013 09:50 AM |
This works fine for me, tested. You didn't change anything?
local brick = script.Parent local canopy = Workspace.TheCanopy local db = true function touched(hit) if hit and hit.Parent:findFirstChild("Humanoid") and db then db = false p = game.Players:GetPlayerFromCharacter(hit.Parent) brick.BrickColor = BrickColor.new(tostring(p.TeamColor)) if canopy.Light.BrickColor == BrickColor.new("Medium stone grey") then canopy.Head.Position = Vector3.new(182.5, 282.4, 1290) elseif canopy.Light.BrickColor == BrickColor.new("Bright Blue") then canopy.Head.Position = Vector3.new(188.5, 262, -129) elseif canopy.Light.BrickColor == BrickColor.new("Bright Red") then canopy.Head.Position = Vector3.new(179.5, 262, -129) end print ("CP Accepted") wait() db = true end end
brick.Touched:connect(touched)
|
|
|
| Report Abuse |
|
|
Azarth
|
  |
| Joined: 17 Aug 2012 |
| Total Posts: 2760 |
|
|
| 21 Jun 2013 09:51 AM |
| @tid you changed the single = I put to a double that's wrong. |
|
|
| Report Abuse |
|
|
Tidbit1
|
  |
| Joined: 15 Jun 2009 |
| Total Posts: 92 |
|
|
| 21 Jun 2013 09:57 AM |
| I'll try it again - thank you so much!!! |
|
|
| Report Abuse |
|
|
Tidbit1
|
  |
| Joined: 15 Jun 2009 |
| Total Posts: 92 |
|
|
| 21 Jun 2013 10:01 AM |
| I didn't edit it - it printed "CP Accepted", Light turned blue, yet the block "Head" did not move. |
|
|
| Report Abuse |
|
|
Azarth
|
  |
| Joined: 17 Aug 2012 |
| Total Posts: 2760 |
|
|
| 21 Jun 2013 10:10 AM |
| Put cp accepted before the first end. It moved for me, did you make sure your TeamColor matched one in the script? |
|
|
| Report Abuse |
|
|
Tidbit1
|
  |
| Joined: 15 Jun 2009 |
| Total Posts: 92 |
|
|
| 21 Jun 2013 10:18 AM |
My team color is Bright blue - so yes, it should work. Maybe I accidentally did something to it, here it is again: local brick = script.Parent local canopy = Workspace.TheCanopy local db = true function touched(hit) if hit and hit.Parent:findFirstChild("Humanoid") and db then db = false p = game.Players:GetPlayerFromCharacter(hit.Parent) brick.BrickColor = BrickColor.new(tostring(p.TeamColor)) if canopy.Light.BrickColor == BrickColor.new("Medium stone grey") then canopy.Head.Position = Vector3.new(182.5, 282.4, 1290) elseif canopy.Light.BrickColor == BrickColor.new("Bright Blue") then canopy.Head.Position = Vector3.new(188.5, 262, -129) elseif canopy.Light.BrickColor == BrickColor.new("Bright Red") then canopy.Head.Position = Vector3.new(179.5, 262, -129) print ("CP Accepted") end wait() db = true end end |
|
|
| Report Abuse |
|
|
Tidbit1
|
  |
| Joined: 15 Jun 2009 |
| Total Posts: 92 |
|
|
| 21 Jun 2013 10:23 AM |
Oh, wait - (now this might make me look incredibly stupid) did I ever tell you that Light and Head are both in a Model called "The Canopy"? If not, you may have to help me with it again (because I'm a horrible scripter). Thanks again!!! |
|
|
| Report Abuse |
|
|
Azarth
|
  |
| Joined: 17 Aug 2012 |
| Total Posts: 2760 |
|
|
| 21 Jun 2013 10:36 AM |
idk if you forgot to paste the event, but you didn't have one in your paste.
http://www.roblox.com/as-pdasd-item?id=119866935 |
|
|
| Report Abuse |
|
|
Tidbit1
|
  |
| Joined: 15 Jun 2009 |
| Total Posts: 92 |
|
|
| 21 Jun 2013 10:41 AM |
| Should the script go in Light, or should I have a seperate part like you do? |
|
|
| Report Abuse |
|
|
Tidbit1
|
  |
| Joined: 15 Jun 2009 |
| Total Posts: 92 |
|
|
| 21 Jun 2013 10:44 AM |
Wait, it works now! Thanks a lot! I'll get back to you as I need to make some finishing touches - |
|
|
| Report Abuse |
|
|
Tidbit1
|
  |
| Joined: 15 Jun 2009 |
| Total Posts: 92 |
|
|
| 21 Jun 2013 10:51 AM |
Yes, it worked THANK YOU!!! Now I just need to configure it for each command post on the battlefield :3 |
|
|
| Report Abuse |
|
|