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: Turning invisible while standing in an area

Previous Thread :: Next Thread 
wow75 is not online. wow75
Joined: 16 Jan 2009
Total Posts: 951
06 Apr 2014 10:32 PM
I feel like the problem is the position stuff, but it just straight doesn't work.

Character = script.Parent
X = 1
local d = Character.HumanoidRootPart.Position
while true do
wait(X)
if d.z <= 21.4 and d.z >= -11.6 and d.x <= -252.8 and d.x >= -285.8 and d.y < 40.7 then
X = 0.1
for _,v in pairs(Character:GetChildren()) do
if v.ClassName == "Part" and v.Name ~= "HumanoidRootPart" then
if v.Name == "Head" then
v.face.Transparency = 1
end
v.Transparency = v.Transparency +0.075
elseif v.ClassName == "Hat" then
v.Handle.Transparency = v.Handle.Transparency +0.075
end
end
else
X = 1
for _,v in pairs(Character:GetChildren()) do
if v.ClassName == "Part" and v.Name ~= "HumanoidRootPart" then
if v.Name == "Head" then
v.face.Transparency = 0
end
v.Transparency = 0
elseif v.ClassName == "Hat" then
v.Handle.Transparency = 0
end
end
end
end
Report Abuse
Vexeris is not online. Vexeris
Joined: 03 Apr 2014
Total Posts: 468
06 Apr 2014 11:30 PM
Character = script.Parent
X = 1
local d = Character.Humanoid.Position
while true do
wait(X)
if d.z <= 21.4 and d.z >= -11.6 and d.x <= -252.8 and d.x >= -285.8 and d.y < 40.7 then
X = 0.1
for _,v in pairs(Character:GetChildren()) do
if v.ClassName == "Part" and v.Name ~= "HumanoidRootPart" then
if v.Name == "Head" then
v.face.Transparency = 1
end
v.Transparency = v.Transparency +0.075
elseif v.ClassName == "Hat" then
v.Handle.Transparency = v.Handle.Transparency +0.075
end
end
else
X = 1
for _,v in pairs(Character:GetChildren()) do
if v.ClassName == "Part" and v.Name ~= "HumanoidRootPart" then
if v.Name == "Head" then
v.face.Transparency = 0
end
v.Transparency = 0
elseif v.ClassName == "Hat" then
v.Handle.Transparency = 0
end
end
end
end
Report Abuse
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
06 Apr 2014 11:52 PM
Delete out everything that contains else. That is unnecessary, right?

Try disabling the if (position) then statement and it's end and run it normally.
Report Abuse
wow75 is not online. wow75
Joined: 16 Jan 2009
Total Posts: 951
07 Apr 2014 06:32 PM
Well I'd like them to become visible once they leave the area. When I took out the else it worked, but only if I pasted the script in his character when he was in the area. If I tried anywhere else, it wouldn't work, and no output either. So it seems like it's just checking once and then stopping.
Report Abuse
wow75 is not online. wow75
Joined: 16 Jan 2009
Total Posts: 951
09 Apr 2014 11:42 AM
So I made a really dumbed down version and even that doesn't work...

Character = script.Parent
local d = Character.Head.Position
while true do
if d.z <= 21.4 and d.z >= -11.6 and d.x <= -252.8 and d.x >= -285.8 and d.y < 40.7 then
print("IN ZONE")
else
--other stuff
end
wait(0.1)
end
Report Abuse
powertool is not online. powertool
Joined: 01 Feb 2008
Total Posts: 3771
09 Apr 2014 12:50 PM
Check if the Player's HumanoidRootPart is in a Region3 that you want him/her to be invisible in, if so, set all Parts of that Character invisible. Then, if he walks out (Surround with Region3's on all 6 sides?), set all the parts except for the HumanoidRootPart back to visible.
Report Abuse
wow75 is not online. wow75
Joined: 16 Jan 2009
Total Posts: 951
09 Apr 2014 05:02 PM
Looked it up on the wiki, perfect solution. But how do I find out if it's inside it? FindPartsInRegion3 seems like it wouldn't quite work...
Report Abuse
wow75 is not online. wow75
Joined: 16 Jan 2009
Total Posts: 951
09 Apr 2014 05:35 PM
LENGHTY SCRIPT AHEAD

So here's what I've got.

Character = script.Parent
local d = Character.HumanoidRootPart
local RE = Region3.new(Vector3.new(-285.9, 12.5, -11.7),Vector3.new(-252.7, 44.2, 21.5))
while true do
local tab = {}
for i = 1, #game.Workspace:FindPartsInRegion3(RE,nil,100) do
table.insert(tab, i, game.Workspace:FindPartsInRegion3(RE,nil,100)[i])
end
for _,v in pairs(tab) do
if v == d then
for _,v in pairs(Character:GetChildren()) do
if v.ClassName == "Part" and v.Name ~= "HumanoidRootPart" then
if v.Name == "Head" then
v.face.Transparency = 1
end
v.Transparency = v.Transparency +0.075
elseif v.ClassName == "Hat" then
v.Handle.Transparency = v.Handle.Transparency +0.075
end
end
else
for _,v in pairs(Character:GetChildren()) do
if v.ClassName == "Part" and v.Name ~= "HumanoidRootPart" then
if v.Name == "Head" then
v.face.Transparency = 0
end
v.Transparency = 0
elseif v.ClassName == "Hat" then
v.Handle.Transparency = 0
end
end
end
end
for c = 1,100 do
table.remove(tab,1)
if #tab == 0 then
break
end
end
wait(2)
end
Report Abuse
MTamidex is not online. MTamidex
Joined: 17 Oct 2013
Total Posts: 1092
09 Apr 2014 05:37 PM
It would be easier to make a brick that when you're touching it makes you invisible, but since you want to make it with areas fine.
Report Abuse
wow75 is not online. wow75
Joined: 16 Jan 2009
Total Posts: 951
09 Apr 2014 05:42 PM
Im not really sure how to do that though, like, if you're totally submerged in a brick, it no longer counts collisions; edge on edge contact is considered a touch. And of course, he has to become visible when he leaves, which I think will just be plethora of problems.
Report Abuse
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
09 Apr 2014 05:49 PM
Here is the problem:

local d = Character.Head.Position --store a variable with the head's position

while true do
if (d stuff) then --oh wait, THE D VARIABLE DOESN'T UPDATE!
--stuff
end
end


You can't define the variable with the position inside of it. Try this:

local d = Character.Head

while true do
if (d.Position.X >= blah blah) then --now the position gets updated every loop
--stuff
end
end

Report Abuse
MTamidex is not online. MTamidex
Joined: 17 Oct 2013
Total Posts: 1092
09 Apr 2014 05:51 PM
use the .Touched event like

player = game.Players.LocalPlayer

function onTouched(hit)
if (hit.Parent:findFirstChild("Humanoid") then
player.Torso.Transparency = 1
player.LeftArm.Transparency = 1
player.RightArm.Transparency = 1
player.LeftLeg.Transparency = 1
player.RightLeg.Transparency = 1
end

game.Workspace.InvisibilityBrick.Touched:connect(onTouched)

I will test it and tell you if works
Report Abuse
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
09 Apr 2014 05:52 PM
@MT

He's looking for the character to go invisible if they enter an area, not if they touch a part.
Report Abuse
wow75 is not online. wow75
Joined: 16 Jan 2009
Total Posts: 951
09 Apr 2014 05:56 PM
Clever clever! That explains literally everything. xD
Report Abuse
MTamidex is not online. MTamidex
Joined: 17 Oct 2013
Total Posts: 1092
09 Apr 2014 06:01 PM
yeah but is my script functional? i like to help
Report Abuse
Azureous is not online. Azureous
Joined: 29 Jan 2012
Total Posts: 25287
09 Apr 2014 06:03 PM
local Pos1=CornerBrick1.Position;
local Pos2=CornerBrick2.Position;
local Region=Region3.new(Pos1,Pos2);
while true do
Spawn(function()
for Index,Value in pairs(Workspace:FindPartInRegion3(Region,nil,1000) do
if Value:IsA("Head") and Value.Parent.Name==("Character") then
Spawn(function()
local player=game.Players:GetPlayerFromCharacter(Value.Parent);
for Index=1,#player.Character:GetChildren() do
player.Character:GetChildren()[Index].Transparency=1;
end
end)
end
end
end)
end
Report Abuse
wow75 is not online. wow75
Joined: 16 Jan 2009
Total Posts: 951
09 Apr 2014 06:04 PM
Yes yours would work, but when I leave the area, I would still be invisible. Also some crafty sausage would probably just keep touching the brick over and over and glitch themselves invisible.
Report Abuse
MTamidex is not online. MTamidex
Joined: 17 Oct 2013
Total Posts: 1092
09 Apr 2014 06:15 PM
Mine?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
09 Apr 2014 06:16 PM
yes
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