|
The first script is supposed to make Part2 lower when Part1 is touched, if the positions, and person touching are right, along with making sure it's enabled. The second one lowers it on the same conditions. It lowers, but it wont raise, and the output gives me nothing. Any help would be appreciated.
~~~~~~~~~~~~LOWERING SCRIPT~~~~~~~~~~~~~~~~
c = game.Workspace.Part2.BrickColor --Flag's color
p = game.Workspace.Part1 --Part1
f = p.Touched:connect(onTouched) --Part1 is touched
g = p.Touched:connect(onTouched) --Find who touched Part1
o = game.Workspace.Part2
s = p.LoweringScript.Disabled
t = p.RaisingScript.Disabled
------------------------------------------------------------------------------------------------------------------------
local ispressing = false
if ispressing == false and ispressing ~= nil then --If ispressing is equal to false and it equals something then...
game.Workspace.Part1.Touched:connect(function(hit) --...when it's touched...
ispressing = true --...it is being pressed.
end)
end
script.Parent.Touched:connect(hit)
-----------------------------------------------------------------------------------------------------------------------------
local t = true
if t == true and o.Position.Y >= 14 and o.Position.Y <= 15 then
t = false
else
t = true
end
-----------------------------------------------------------------------------------------------------------------------------
if t == true then
p.Touched:connect(function(g)
if c == (BrickColor.new("Bright red")) and g.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(g.Parent)
if player:IsInGroup(206262) then
if o.Position.Y >= 10 and o.Position.Y <= 57 then --...if the person who's touching it is in (enemy group # goes in parenthesis) then...
end --...do nothing.
end
end
end)
end
-----------------------------------------------------------------------------------------------------------------------------
if t == true then
p.Touched:connect(function(g)
if c == (BrickColor.new("Bright red")) and g.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(g.Parent)
if player:IsInGroup(225681) then
while ispressing == true do --...while allie(s) is/are pressing the brick...
if o.Position.Y >= 16 and o.Position.Y <= 57 then --...and if Part2's "Y" position is between 16 and 56 then...
o.CFrame = o.CFrame + Vector3.new(0, -1.6, 0) --...move Part2 down 1.6 studs...
end
wait(.6)
end
end
end
end)
end
-----------------------------------------------------------------------------------------------------------------------------------------
if t == true then
p.Touched:connect(function(g)
if c == (BrickColor.new("Navy blue")) and g.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(g.Parent)--You made player global before, so you can't use the same thing.
if player:IsInGroup(206262) then
while ispressing == true do --...while enemie(s) is/are pressing the brick...
if o.Position.Y >= 16 and o.Position.Y <= 57 then --...and if Part2's "Y" position is inbetween 16 and 56 then...
o.CFrame = o.CFrame + Vector3.new(0, -1.6, 0) --...move Part2 down 5 studs...
end
wait(.6)
end
end
end
end)
end
------------------------------------------------------------------------------------------------------------------------------------
if t == true then
p.Touched:connect(function(g)
if c == (BrickColor.new("Navy blue")) and g.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(g.Parent)
if player:IsInGroup(225681) then
end --...do nothing.
end
end)
end
-----------------------------------------------------------------------------------------------------------------------------------
script.Parent.TouchEnded:connect(function()
if ispressing == true then
ispressing = false
end
end)
game.Workspace.Part1.Touched:connect()
--------------------------------------------------------------------------------------------------------------------------------------
~~~~~~~~~~~~~~RAISING SCRIPT~~~~~~~~~~~~~~~~~~~~
c = game.Workspace.Part2.BrickColor --Flag's color
p = game.Workspace.Part1 --Part1
f = p.Touched:connect(onTouched) --Part1 is touched
g = p.Touched:connect(onTouched) --Find who touched Part1
o = game.Workspace.Part2
s = p.LoweringScript.Disabled
t = p.RaisingScript.Disabled
------------------------------------------------------------------------------------------------------------------------
local ispressing = false
if ispressing == false and ispressing ~= nil then --If ispressing is equal to false and it equals something then...
game.Workspace.Part1.Touched:connect(function(hit) --...when it's touched...
ispressing = true --...it is being pressed.
end)
end
script.Parent.Touched:connect(hit)
-----------------------------------------------------------------------------------------------------------------------------
local s = false
if s == false and o.Position.Y >= 14 and o.Position.Y <= 15 then
s = true
else
s = false
end
-----------------------------------------------------------------------------------------------------------------------------
if s == true then
p.Touched:connect(function(g)
if c == (BrickColor.new("Bright red")) and g.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(g.Parent)
if player:IsInGroup(206262) then
if o.Position.Y >= 10 and o.Position.Y <= 57 then --...if the person who's touching it is in (enemy group # goes in parenthesis) then...
end --...do nothing.
end
end
end)
end
-----------------------------------------------------------------------------------------------------------------------------
if s == true then
p.Touched:connect(function(g)
if c == (BrickColor.new("Bright red")) and g.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(g.Parent)
if player:IsInGroup(225681) then
while ispressing == true do --...while allie(s) is/are pressing the brick...
if o.Position.Y >= 16 and o.Position.Y <= 57 then --...and if Part2's "Y" position is between 16 and 56 then...
o.CFrame = o.CFrame + Vector3.new(0, -1.6, 0) --...move Part2 down 1.6 studs...
end
wait(.6)
end
end
end
end)
end
-----------------------------------------------------------------------------------------------------------------------------------------
if s == true then
p.Touched:connect(function(g)
if c == (BrickColor.new("Navy blue")) and g.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(g.Parent)--You made player global before, so you can't use the same thing.
if player:IsInGroup(206262) then
while ispressing == true do --...while enemie(s) is/are pressing the brick...
if o.Position.Y >= 16 and o.Position.Y <= 57 then --...and if Part2's "Y" position is inbetween 16 and 56 then...
o.CFrame = o.CFrame + Vector3.new(0, -1.6, 0) --...move Part2 down 5 studs...
end
wait(.6)
end
end
end
end)
end
------------------------------------------------------------------------------------------------------------------------------------
if s == true then
p.Touched:connect(function(g)
if c == (BrickColor.new("Navy blue")) and g.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(g.Parent)
if player:IsInGroup(225681) then
end --...do nothing.
end
end)
end
-----------------------------------------------------------------------------------------------------------------------------------
script.Parent.TouchEnded:connect(function()
if ispressing == true then
ispressing = false
end
end)
game.Workspace.Part1.Touched:connect()
--------------------------------------------------------------------------------------------------------------------------------------
+-Fishy |
|
miz656Join Date: 2010-07-19 Post Count: 15336 |
You used an anonymous function, so you don't have to say the connection line again, just say end) |
|
|
1) Where are you talking about?
2) Keep in mind that these are two different scripts in the same brick. Their not in one literal script, each one has it's own.
+-Fishy |
|
miz656Join Date: 2010-07-19 Post Count: 15336 |
if ispressing == false and ispressing ~= nil then --If ispressing is equal to false and it equals something then...
game.Workspace.Part1.Touched:connect(function(hit) --...when it's touched...
ispressing = true --...it is being pressed.
end)
end
script.Parent.Touched:connect(hit)
You have two connection lines...When you have an anonymous function... No point of the second connection line. |
|
|
One, I am connecting when it is hit, the other is when it stops being hit. I don't think that that's the problem because the lowering script works perfectly, but when Part2 hits bottom, it wont go back up, so I think it's somewhere in either the raising script, or when I try to change the disabled.
+-Fishy |
|
miz656Join Date: 2010-07-19 Post Count: 15336 |
"the other is when it stops being hit."
Why not use the TouchEnded event? |
|
|
|
I use TouchEnded at the end of both...
+-Fishy |
|
|
dave2011Join Date: 2010-10-02 Post Count: 10581 |
tl;dr couldnt you just make the brick lower by .6 or whatever every second or whatever |
|
|
Umm...I do do that. That part of the script works. It's not raising back up when it is at a certain position...
+-Fishy |
|
|
|
I'm still lost over here...
+-Fishy |
|
|
miz656Join Date: 2010-07-19 Post Count: 15336 |
Since you are desperate for help tell me the PART you think messes up. The script, post it. |
|
|
I think it's the raising script that breaks. I think it has something to do with the 's' and 't' variables too, I don't think I did those right. Maybe somewhere in this part?
if s == true then
p.Touched:connect(function(g)
if c == (BrickColor.new("Bright red")) and g.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(g.Parent)
if player:IsInGroup(225681) then
while ispressing == true do --...while allie(s) is/are pressing the brick...
if o.Position.Y >= 16 and o.Position.Y <= 57 then --...and if Part2's "Y" position is between 16 and 56 then...
o.CFrame = o.CFrame + Vector3.new(0, 1.6, 0) --...move Part2 down 1.6 studs...
end
wait(.6)
end
end
end
end)
end
+-Fishy |
|
|
miz656Join Date: 2010-07-19 Post Count: 15336 |
Why do you have g as your arguement/ |
|
|
That's not the problem... If it was, then why does it work in the lowering script?
+-Fishy |
|
miz656Join Date: 2010-07-19 Post Count: 15336 |
Bro if I were you I would just rewrite it because really, I don't know what's happening. I would have to see your game to fix this. |
|
|
Ok. I you want to see my place, then go to my last place called "Testing area". It's a flag(Part2) that is supposed to lower, change color, and raise again. But it all depends on who is touching it, and the color the brick is.
+-Fishy
|
|
|
miz656Join Date: 2010-07-19 Post Count: 15336 |
When I'm on the part it doesn't lower...It doesn't do anything. |
|
|
That's because your not in either of the two groups listed used in the script.
+-Fishy |
|
miz656Join Date: 2010-07-19 Post Count: 15336 |
-_-
I would just rewrite it. Because I got no time to fix this and I don't think no one else is gonna help since this thread has been here for a while. |
|