cdw500Join Date: 2014-06-11 Post Count: 141 |
I have tried checking for the parts position by:
if part.Position == Vector3.new(0,0,0)
But that doesn't seem to work any solutions? |
|
GoulstemJoin Date: 2012-07-04 Post Count: 7177 |
if Part.CFrame == CFrame.new(0,0,0) then
Idk why these wouldn't work |
|
cdw500Join Date: 2014-06-11 Post Count: 141 |
This did not work. I will put the entire script at bottom for possible debugging.
local DoorL = script.Parent.Parent.DoorL
local DoorR = script.Parent.Parent.DoorR
local Ele = script.Parent.Parent.ElevatorMain.Floor
local wait = false
script.Parent.ClickDetector.MouseClick:connect(function()
if wait == false then
print("1")
if Ele.CFrame == CFrame.new(-4.091, 0.591, 71.459) then
print("2")
for i=1, 20 do
Wait()
DoorL.CFrame = DoorL.CFrame + Vector3.new(0.1,0,0)
DoorR.CFrame = DoorR.CFrame + Vector3.new(-0.1,0,0)
end
wait = true
end
end
end)
|
|
cdw500Join Date: 2014-06-11 Post Count: 141 |
Any one have any solutions? |
|
|
if part.Position.Y == 0 and part.Position.X == 0 and part.Position.Z == 0 then |
|
cdw500Join Date: 2014-06-11 Post Count: 141 |
I tryed this in a separate part and it did not work here is the script below.
if script.Parent.Position.Y == 0.573 and script.Parent.Position.X == 0 and script.Parent.Position.Z == 0 then
print("Here")
end |
|
SpectrialJoin Date: 2012-03-15 Post Count: 3348 |
are you looping it or using a .changed function? try either of these two.
while wait(0.1) do
if part.Position == Vector3.new(0,0,0) then
--code
end
end
or
part.Changed:connect(function(a)
if part.Position == Vector3.new(0,0,0) then
--code
end
end)
|
|
|
The problem seems to be that you have "wait" as a variable, thus confusing the script. The solution would simply be to change your BoolValue "wait" to something else like "time" or "enabled." |
|
|
Don't use "local wait" at the beginning.
wait is only meant to be used as this "wait()"
you can't use it as a variable. It confuses the script.
so basically what @above said. |
|
cdw500Join Date: 2014-06-11 Post Count: 141 |
Neither of those worked I made a separate part and put a script in it and tryed both with its position and they did not work here is the script.
script.Parent.Changed:connect(function(a)
if script.Parent.Position == Vector3.new(-7, 0.589, 10) then
print("Hi")
end
end) |
|
SpectrialJoin Date: 2012-03-15 Post Count: 3348 |
i have a hunch that your part just never hits the exact spot, so i'd put a part where you want your elevator to go and then use magnitude to detect it. |
|
|
I've had this problem before.
Here is my solution to what I think the problem is.
function AreVectorsEqual(Value1, Value2)
if math.floor(Value1.X*100) == math.floor(Value2.X*100) and
math.floor(Value1.Y*100) == math.floor(Value2.Y*100) and
math.floor(Value1.Z*100) == math.floor(Value2.Z*100) then
return true
else
return false
end |
|
cdw500Join Date: 2014-06-11 Post Count: 141 |
But the part is in the exact position that i have it set as. |
|
|
@cdw,
1. What exactly is not working? Is it the entire script, or just the part you are inquiring on?
2. What have you already tried? |
|
Brick_manJoin Date: 2009-11-20 Post Count: 5634 |
Roblox scripts never round. Positions do; so yea. Use
if (Part1.Position-Goal.Position).magnitude < 1 then
print'yes'
end |
|
cdw500Join Date: 2014-06-11 Post Count: 141 |
Do you mind explaining this to me? |
|
SpectrialJoin Date: 2012-03-15 Post Count: 3348 |
instead of using the exact position, we're trying to get it just within the ballpark with a margin of about 1 stud. |
|
cdw500Join Date: 2014-06-11 Post Count: 141 |
it is just the check position part and I have tryed to check the CFrame and the Vector3 |
|
cdw500Join Date: 2014-06-11 Post Count: 141 |
I've tryed using magnitude and putting the part under and on top of the part or goal it it did not print yes. i think I need a better explanation of how each part works. |
|
|
The problem is that even though it claims to be in the exact position, it isn't.
So you are comparing two values like
1.2830000000138
and
1.2830000000251
They are close, but not the same.
So use the code I mentioned earlier to round the value up to the hunredths' place. |
|
cdw500Join Date: 2014-06-11 Post Count: 141 |
I have found a nice easy solution with magnitude thanks for all of the help! |
|