this doesnt appear to be doing the trick.
incoporating it into my own script (BadgeService
items negated for the sake of easy debugging),
local part = script.Parent
local ootherPart = game.Workspace.Jeep1
local function onPartTouched(ootherPart)
print(part.Name .. " has touched " .. ootherPart.Name)
local partPos = part.Position
local otherpartPos = ootherPart.Position
local startTime = time()
repeat
task.wait()
until time()-startTime >= 8
if time()-startTime >= 8 and (partPos-otherpartPos).Magnitude >= 2 then
print('car not stuck')
end
if time()-startTime >= 8 and (partPos-otherpartPos).Magnitude <= 2 then
print('car is stuck')
print('badge awarded')
end
end
part.Touched:Connect(onPartTouched)
when the game initially loads, the console returns “car is not stuck”, which seems correct, right?
however, when the car is actually firmly stuck in part
, the console returns “car is not stuck”. not once is “car is stuck” printed.
ive reversed the >= and <= on both if
statements to no success- swapping the two results in “car is stuck” and “badge awarded” being printed the second the game loads. using elseif
also gives me the same issue.
also, for some reason, the game detects other parts as touching it even though i only want it to react to parts from ootherPart
. i thought renaming it would fix it, again to no avail. the game detects a part thats properly attached to part
as well as all the parts of a players Humanoid
.
im guessing this is a correct function of onPartTouched
? but i defined ootherPart
as what i want it to detect, so i dont know whats up here or how to fix it.
this isnt really my problem though, as the prints do only react to ootherPart
as i want them too, so ignore this if you want.
are my and
statements not the right statements to use? should i swap one or both for or
? my worry is that, again, this will negate one of the two variables this requires for the badge to be properly given.
im really stumped.
i tried working out a new version of the initial script to see if what im trying to do makes any more sense. i just wanna see if part a is stuck in part b and reward a badge if so.
local part = script.Parent
local otherPart = game.Workspace.Jeep1
local partPos = part.Position
local otherpartPos = otherPart.Position
local magni = (partPos-otherpartPos).Magnitude
local function onPartTouched(otherPart)
local startTime = time()
local timerUp = false
repeat
task.wait()
until time()-startTime >= 8
end
if time()-startTime >= 8 then
local timerUp = true
end
if timerUp == true then
if magni <= 2 then
print('car is stuck')
print('badge awarded')
else
print('car not stuck')
end
end
i really dont know what to do, ill try asking elsewhere, but let me know if you come up with anything.