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 » Scripters
Home Search
 

Re: Fog of War; not working!

Previous Thread :: Next Thread 
Hvxbyte is not online. Hvxbyte
Joined: 19 Aug 2015
Total Posts: 410
29 Aug 2015 09:23 AM
Obviously not the best code ever, but basically, there's territories, and each territory has a part (fog of war), but I want to get the touching parts of YOUR territories, and destroy the fog of war part.

No errors, but nor does it work.

local player = game.Players.LocalPlayer

local map = script.Parent

for _, country in next, map:GetChildren() do
if country:IsA("Model") then
for _, territory in next, country:GetChildren() do
if territory:IsA("Part") then
territory.Changed:connect(function(BrickColor)
if BrickColor == BrickColor.new(player.TeamColor.Name) then
for _, connectedPart in next, territory:GetTouchingParts() do
if connectedPart.Name == "Territory" then
connectedPart:FindFirstChild("Fog of War"):Destroy()
end
end
end
end)
end
end
end
end
Report Abuse
Hvxbyte is not online. Hvxbyte
Joined: 19 Aug 2015
Total Posts: 410
29 Aug 2015 09:25 AM
Just to break it down a little.

function fogOfWar(part)
for _, connectedPart in next, part:GetTouchignParts() do
if connectedPart.Name == "Territory" then
connectedPart:FindFirstChild("Fog of War"):Destroy()
end
end
end

for _, country in next, map:GetChildren() do
if country:IsA("Model") then
for _, territory in next, country:GetChildren() do
if territory:IsA("Part") then
territory.Changed:connect(function(BrickColor)
if BrickColor == BrickColor.new(player.TeamColor.Name) then
fogOfWar(territory)
end
end)
end
end
end
end
Report Abuse
patzit is not online. patzit
Joined: 23 Mar 2010
Total Posts: 42
29 Aug 2015 09:57 AM
Notice that GetTouchingParts only returns parts that intersect the part you call it on, not adjacent ones. If this is the problem then try to increase the size of your "Fog of war" bricks to intersect your "territory" parts.
Report Abuse
Hvxbyte is not online. Hvxbyte
Joined: 19 Aug 2015
Total Posts: 410
29 Aug 2015 10:04 AM
Oh, okay!
Report Abuse
Hvxbyte is not online. Hvxbyte
Joined: 19 Aug 2015
Total Posts: 410
29 Aug 2015 10:07 AM
I've temporarily removed the conditional statement and replace it with print(connectedPart.Name)... doesn't seem to work.
Report Abuse
Hvxbyte is not online. Hvxbyte
Joined: 19 Aug 2015
Total Posts: 410
29 Aug 2015 08:52 PM
Bump, updated code-ish. Tried to use a repeat loop to see if it wasn't working the first time around, still no luck. Am I doing something wrong?

local player = game.Players.LocalPlayer

local activeMap = game.Workspace:FindFirstChild("Active Map")

function fogOfWar(part)
part.Changed:connect(function(property)
if property == "BrickColor" then
if property == player.TeamColor then
for _, connected in next, part:GetTouchingParts() do
if connected.Name == "Fog of War" then
connected:Destroy()
end
end
end
end
end)
end

repeat
wait()
for _, map in next, activeMap:GetChildren() do
if map:IsA("Model") then
for _, country in next, map:GetChildren() do
if country:IsA("Model") then
for _, territory in next, country:GetChildren() do
if territory:IsA("Part") then
fogOfWar(territory)
end
end
end
end
end
end
until
player == nil
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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